10 Useful Linux Networking Commands
Zeeshan Mir Baz has collected the information from this webiste:https://geekflare.com/linux-networking-commands/ in this article
said that:

Linux is a most powerful operating system, and networking is an essential part of servers.
It offers many inbuilt commands to diagnose for network issues.
In this article, I will show you useful Linux networking commands, which will help you in troubleshooting.
Mostly we use this command to check the IP address assigned to the system.
Destination host or IP is mandatory parameter to use this utility
It performs DNS lookups and displays the answers that are returned from the name servers.
netstat with head output is very helpful while performing web server troubleshooting.
Ex:
Also list the logged in users and system load average for the past 1, 5, and 15 minutes.
Usage example:
said that:

Linux is a most powerful operating system, and networking is an essential part of servers.
It offers many inbuilt commands to diagnose for network issues.
In this article, I will show you useful Linux networking commands, which will help you in troubleshooting.
1Ifconfig
ifconfig utility is used to configure network interface parameters.Mostly we use this command to check the IP address assigned to the system.
[root@localhost ~]# ifconfig -a eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 00:0c:29:c5:a5:61 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 0 (Local Loopback) RX packets 2 bytes 140 (140.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2 bytes 140 (140.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@localhost ~]#
2traceroute
traceroute print the route packets take to network host.Destination host or IP is mandatory parameter to use this utility
[root@localhost ~]# traceroute geekflare.com traceroute to geekflare.com (162.159.243.243), 30 hops max, 60 byte packets 1 172.16.179.2 (172.16.179.2) 0.154 ms 0.074 ms 0.074 ms 2 * * * 3 * * *
3dig
dig (Domain Information Groper) is a flexible tool for interrogating DNS name servers.It performs DNS lookups and displays the answers that are returned from the name servers.
[root@localhost ~]# dig geekflare.com ; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> geekflare.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18699 ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; MBZ: 0005 , udp: 4000 ;; QUESTION SECTION: ;geekflare.com. IN A ;; ANSWER SECTION: geekflare.com. 5 IN A 162.159.244.243 geekflare.com. 5 IN A 162.159.243.243 ;; Query time: 6 msec ;; SERVER: 172.16.179.2#53(172.16.179.2) ;; WHEN: Sun May 01 23:28:19 PDT 2016 ;; MSG SIZE rcvd: 74 [root@localhost ~]#
4telnet
telnet connect destination host:port via a telnet protocol if connection establishes means connectivity between two hosts is working fine.[root@localhost ~]# telnet geekflare.com 443 Trying 162.159.244.243... Connected to geekflare.com. Escape character is '^]'.
5nslookup
nslookup is a program to query Internet domain name servers.[root@localhost ~]# nslookup geekflare.com Server: 172.16.179.2 Address: 172.16.179.2#53 Non-authoritative answer: Name: geekflare.com Address: 162.159.243.243 Name: geekflare.com Address: 162.159.244.243 [root@localhost ~]#
6netstat
Netstat command allows you a simple way to review each of your network connections and open sockets.netstat with head output is very helpful while performing web server troubleshooting.
[root@localhost ~]# netstat Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 172.16.179.135:58856 mirror.comp.nus.ed:http TIME_WAIT tcp 0 0 172.16.179.135:34444 riksun.riken.go.jp:http ESTABLISHED tcp 0 0 172.16.179.135:37948 mirrors.isu.net.sa:http TIME_WAIT tcp 0 0 172.16.179.135:53128 ossm.utm.my:http TIME_WAIT tcp 0 0 172.16.179.135:59723 103.237.168.15:http TIME_WAIT tcp 0 0 172.16.179.135:60244 no-ptr.as20860.net:http TIME_WAIT
7scp
scp allows you to secure copy files to and from another host in the network.Ex:
scp $filename user@targethost:/$path
8w
w prints a summary of the current activity on the system, including what each user is doing, and their processes.Also list the logged in users and system load average for the past 1, 5, and 15 minutes.
[root@localhost ~]# w 23:32:48 up 2:52, 2 users, load average: 0.51, 0.36, 0.19 USER TTY LOGIN@ IDLE JCPU PCPU WHAT chandan :0 20:41 ?xdm? 7:07 0.13s gdm-session-worker [pam/gdm-password] chandan pts/0 20:42 0.00s 0.23s 3.42s /usr/libexec/gnome-terminal-server [root@localhost ~]#
9nmap
nmap is a one of the powerful commands, which checks the opened port on the server.Usage example:
nmap $server_name
10Enable/Disable Network Interface
You can enable or disable the network interface by using ifup/ifdown commands with ethernet interface parameter.To enable eth0
#ifup eth0
To disable eth0
#ifdown eth0I hope above Linux Commands help you to gather network information or troubleshoot the networking issue. If you are looking to learn Networking in details, then check out this great online course by SONIC.
Comments
Post a Comment