Some useful linux networking commands

In this section we will discuss the some frequently used linux commands to check the network connectivity status.

1. ping –ping is the most common method used to test network connectivity across multiple networks. ping sends ICMP echo packets that request a corresponding ICMP echo-reply response from the device at the target address. For more information regarding this command, please refer the man page of this coomand.

example:

ping www.yahoo.com
PING www.yahoo-ht3.akadns.net (87.248.113.14) 56(84) bytes of data.
64 bytes from f1.us.www.vip.ird.yahoo.com (87.248.113.14): icmp_seq=1 ttl=51 tim e=211 ms
64 bytes from f1.us.www.vip.ird.yahoo.com (87.248.113.14): icmp_seq=2 ttl=51 tim e=210 ms
64 bytes from f1.us.www.vip.ird.yahoo.com (87.248.113.14): icmp_seq=3 ttl=51 tim e=210 ms
64 bytes from f1.us.www.vip.ird.yahoo.com (87.248.113.14): icmp_seq=4 ttl=51 tim e=210 ms
64 bytes from f1.us.www.vip.ird.yahoo.com (87.248.113.14): icmp_seq=5 ttl=51 time=211 ms
64 bytes from f1.us.www.vip.ird.yahoo.com (87.248.113.14): icmp_seq=6 ttl=51 time=211 ms

— www.yahoo-ht3.akadns.net ping statistics —
6 packets transmitted, 6 received, 0% packet loss, time 5001ms
rtt min/avg/max/mdev = 210.443/210.951/211.401/0.576 ms

telnet — telnet is the most easy way to tell if a remote server is listening on a specific TCP port. By default, telnet will try to connect on TCP port 23, but we can specify other TCP ports by typing them in after the target IP address. For more information regarding this command, please refer the man page of this coomand.

example:

telnet 192.168.1.1 80

netstat — netstat is very useful command in helping to determine the source of network related problems. Using netstat with the -an option lists all the TCP ports on which our Linux server is listening, including all the active network connections to and from server. For more information regarding this command, please refer the man page of this coomand.

example:

netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:2208 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:2401 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5019 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:41641 127.0.0.1:39743 ESTABLISHED
tcp 0 0 ::ffff:127.0.0.1:1440 :::* LISTEN
tcp 0 0 ::ffff:203.122.58.144:80 :::* LISTEN

MTR–Matt’s Traceroute is an application we can use to do a repeated traceroute in real times. it dynamically shows the round-trip time to reach each hop along the traceroute path. For more information regarding this command, please refer the man page of this coomand.

TCPDUMP — tcpdump command is the most popular packages for viewing the flow of data through Linux server ’s NIC card. One of the most common uses of tcpdump is to determine whether we are getting basic two-way communication. For more information regarding this command, please refer the man page of this coomand.

nslookup — The nslookup command can be used to get the associated IP address of domain and vice versa. The nslookup command is very easy to use; we just need to type the command, followed by the IP address or Web site name we want to query. For more information regarding this command, please refer the man page of this coomand.

example:

nslookup www.mobigyan.com

nmap — we can use the nmap command to determine all the TCP/IP ports on which a remote server is listening. It can be used in a corporate environment to detect vulnerabilities in network, such as servers running unauthorized network applications. For more information regarding this command, please refer the man page of this coomand.

ifconfig — Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argument is given, it displays the status of all interfaces, even those that are down. Otherwise, it configures an interface. For more information regarding this command, please refer the man page of this coomand.

mii-tool — mii-tool provide reports on the link status and duplex settings for supported NICs. When used without any switches, mii-tool gives a very brief report. Use it with the -v switch because it provides more information on the supported autonegotiation speeds of the NIC, and this can be useful in troubleshooting speed and duplex issues. For more information regarding this command, please refer the man page of this coomand.

Source — linux man pages and internet.