farhansadik / echominal

This script a simple manager for termux. User can use is in a short way. This script is very helpful for beginners
GNU General Public License v3.0
5 stars 0 forks source link

add data from SysAdmin.bash file options ~ 2 3 7 #47

Closed farhansadik closed 3 years ago

farhansadik commented 3 years ago

Options

2. Hostname and dns info
3. Network info
7. Get my ip address
farhansadik commented 3 years ago

2) host_info ;;

# Purpose - Get info about host such as dns, IP, and hostname
function host_info(){
    local dnsips=$(sed -e '/^$/d' /etc/resolv.conf | awk '{if (tolower($1)=="nameserver") print $2}')
    write_header " Hostname and DNS information "
    echo "Hostname : $(hostname -s)"
    echo "DNS domain : $(hostname -d)"
    echo "Fully qualified domain name : $(hostname -f)"
    echo "Network address (IP) : $(hostname -i)"
    echo "DNS name servers (DNS IP) : ${dnsips}"
    pause
}

3) net_info ;;

# Purpose - Network inferface and routing info
function net_info(){
    devices=$(netstat -i | cut -d" " -f1 | egrep -v "^Kernel|Iface|lo")
    write_header " Network information "
    echo "Total network interfaces found : $(wc -w <<<${devices})"

    echo "*** IP Addresses Information ***"
    ip -4 address show

    echo "***********************"
    echo "*** Network routing ***"
    echo "***********************"
    netstat -nr

    echo "**************************************"
    echo "*** Interface traffic information ***"
    echo "**************************************"
    netstat -i

    pause 
}

7) ip_info ;;

# Purpose - Get Public IP address form your ISP
function ip_info(){
    cmd='curl -s'
    write_header " Public IP information "
    ipservice=checkip.dyndns.org
    pipecmd=(sed -e 's/.*Current IP Address: //' -e 's/<.*$//') #using brackets to use it as an array and avoid need of scaping
    $cmd "$ipservice" | "${pipecmd[@]}"
    pause
}