This command will return only the IP address of the host.
ubuntu ~ $ hostname -i 172.31.20.16 |
Querying for all local IP addresses on the host.
ubuntu ~ $ hostname -I 172.31.20.16 10.8.0.1 |
This simple script will ping Google and will check the return value of the ping command to see if the Internet is up or not.
ping -c 1 google.com if [ "$?" == "0" ]; then; echo "Hi." else echo "The Internet is down." fi |
This is yet another way to get IP address information from the host.
ubuntu ~ $ ip a | grep inet inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host inet 172.31.20.16/20 brd 172.31.31.255 scope global eth0 inet6 fe80::4d6:3aff:fea8:8213/64 scope link inet 10.8.0.1 peer 10.8.0.2/32 scope global tun1194 |
Use the iptables-save command to dump your iptables rules.
ubuntu ~ $ sudo iptables-save # Generated by iptables-save v1.4.21 on Mon Jun 15 03:38:37 2015 *nat :PREROUTING ACCEPT [2326038:117167934] :INPUT ACCEPT [2144060:106680741] :OUTPUT ACCEPT [74650:5494320] :POSTROUTING ACCEPT [74629:5493133] -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to-source 54.66.223.254 COMMIT # Completed on Mon Jun 15 03:38:37 2015 # Generated by iptables-save v1.4.21 on Mon Jun 15 03:38:37 2015 *filter :INPUT ACCEPT [17240345:7240229224] :FORWARD ACCEPT [16635611:20391694822] :OUTPUT ACCEPT [19729123:22439838587] COMMIT # Completed on Mon Jun 15 03:38:37 2015 |
The nslookup command is used to retrieve DNS information about a certain host. This returns the DNS servers that service that website/host.
ubuntu ~ $ nslookup facebook.com
Server: 172.31.0.2
Address: 172.31.0.2#53
Non-authoritative answer:
Name: facebook.com
Address: 173.252.120.6 |
Use netstat to list all Internet connections from your machine. Here I am listing all of the listening connections on my cloud instance.
ubuntu ~ $ netstat -l Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 localhost:mysql *:* LISTEN tcp 0 0 *:ssh *:* LISTEN tcp 0 0 *:https *:* LISTEN tcp6 0 0 [::]:ssh [::]:* LISTEN udp 0 0 *:bootpc *:* udp 0 0 *:10995 *:* udp 0 0 *:2302 *:* udp 0 0 *:2303 *:* udp 0 0 *:2304 *:* udp 0 0 *:2305 *:* udp6 0 0 [::]:13242 [::]:* Active UNIX domain sockets (only servers) Proto RefCnt Flags Type State I-Node Path unix 2 [ ACC ] SEQPACKET LISTENING 1171791 /run/udev/control unix 2 [ ACC ] STREAM LISTENING 73100 @/com/ubuntu/upstart unix 2 [ ACC ] STREAM LISTENING 8809 /var/run/dbus/system_bus_socket unix 2 [ ACC ] STREAM LISTENING 9104 /var/run/acpid.socket unix 2 [ ACC ] STREAM LISTENING 640253 /var/run/mysqld/mysqld.sock |
To get more DNS information about a host, use the host command like this.
ubuntu ~ $ host -a yahoo.com Trying "yahoo.com" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50687 ;; flags: qr rd ra; QUERY: 1, ANSWER: 12, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;yahoo.com. IN ANY ;; ANSWER SECTION: yahoo.com. 3600 IN NS ns1.yahoo.com. yahoo.com. 3600 IN NS ns2.yahoo.com. yahoo.com. 3600 IN NS ns3.yahoo.com. yahoo.com. 3600 IN NS ns4.yahoo.com. yahoo.com. 3600 IN NS ns5.yahoo.com. yahoo.com. 3600 IN NS ns6.yahoo.com. yahoo.com. 87 IN MX 1 mta6.am0.yahoodns.net. yahoo.com. 87 IN MX 1 mta7.am0.yahoodns.net. yahoo.com. 87 IN MX 1 mta5.am0.yahoodns.net. yahoo.com. 256 IN A 206.190.36.45 yahoo.com. 256 IN A 98.138.253.109 yahoo.com. 256 IN A 98.139.183.24 Received 262 bytes from 172.31.0.2#53 in 80 ms |