In our Previous Linux guide, I mentioned the best Tips and Tricks for Linux and review of Linux application. Now in this guide, I am going to discuss the best essential & useful Linux network commands list. If you are looking for the useful Linux network commands list then you at right place and I going to give you the best reason and ways to use listed Linux network commands. Here you will also get the best Linux Network Commands cheat sheet.
Listed commands are also useful Linux network troubleshooting cheat sheet. Many of them are also best Linux network configuration command line. These Linux network configuration commands are going to help you in set up your network in best ways. Even they also protect you from hacking. Maintaining of system and network up and running is a task of System / Network Administrator’s job.
- List of Essential & Useful Linux Network Commands.
- ifconfig (interface configurator)
- PING (Packet Internet Groper)
- NETSTAT (Network Statistic)
- ARP (Address Resolution Protocol)
- system-config-network – GUI Tool
List of Essential & Useful Linux Network Commands.
ifconfig (interface configurator)
This command is used to show your network configuration IP Address, Hardware and MAC address and also MTU (Maximum transmission unit) size. It is also used to configure network interfaces enable or disable interface on demand.
Enable or Disable Specific Interface
Follow the commands to Enable or Disable specific interface.
Enable ( ifup )
# ifup eth0
Disable ( Ifdown )
# ifdown eth0
Setting MTU Size
By default MTU size is 1500. You can set required MTU size with below command by replacing XXXX with size.
# ifconfig eth0 mtu XXXX
Read More:- Top Useful CMD Commands You Should Know.
PING (Packet Internet Groper)
This command sends packet requests to the address you specify to test the connectivity between 2 nodes. Whether it is Local Area Network (LAN) or Wide Area Network (WAN). Ping uses ICMP (Internet Control Message Protocol) to communicate to other devices. You can ping hostname of IP address using the command below.
# ping teletrickmania.com PING teletrickmania.com (126.96.36.199): 56 data bytes 64 bytes from 188.8.131.52: icmp_seq=0 ttl=46 time=506.855 ms 64 bytes from 184.108.40.206: icmp_seq=1 ttl=46 time=729.998 ms Request timeout for icmp_seq 2 64 bytes from 220.127.116.11: icmp_seq=2 ttl=46 time=1363.267 ms 64 bytes from 18.104.22.168: icmp_seq=3 ttl=46 time=769.473 ms 64 bytes from 22.214.171.124: icmp_seq=4 ttl=46 time=788.485 ms 64 bytes from 126.96.36.199: icmp_seq=5 ttl=46 time=1626.689 ms 64 bytes from 188.8.131.52: icmp_seq=6 ttl=46 time=1046.970 ms 64 bytes from 184.108.40.206: icmp_seq=7 ttl=46 time=649.618 ms 64 bytes from 220.127.116.11: icmp_seq=8 ttl=46 time=669.029 ms
Note:- The ping command will keep executing unless you ping with -c option to exit after N number of requests.
NETSTAT (Network Statistic)
Netstat has a ton of options. This command is used to display connection info including open sockets and routeing tables. Add the option -r to display information on the routeing table. Add the option -p to display information of programs connected to the open sockets.
# netstat -r Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.50.1 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 0 0 0 eth0 default 192.168.50.2 0.0.0.0 UG 0 0 0 eth0
This command is used to find DNS related query.
# nslookup teletrickmania.com Server: 2405:200:800::1 Address: 2405:200:800::1#53 Non-authoritative answer: Name: teletrickmania.com Address: 18.104.22.168
This is a very useful Linux networking command. It shows some details about the domain which is in public.
Domain Name: TELETRICKMANIA.COM Registry Domain ID: 2032254957_DOMAIN_COM-VRSN Registrar WHOIS Server: whois.fastdomain.com Registrar URL: http://www.fastdomain.com Updated Date: 2017-05-25T07:26:34Z Creation Date: 2016-05-30T12:46:14Z Registry Expiry Date: 2018-05-30T12:46:14Z Registrar: FastDomain, Inc. Registrar IANA ID: 1154 Registrar Abuse Contact Email: Registrar Abuse Contact Phone: Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Name Server: NS1.BLUEHOST.COM Name Server: NS2.BLUEHOST.COM DNSSEC: unsigned
It captures packets off a network interface and interprets them for you. It can be also used to save entire packets for later inspection. Tcpdump also needs admin permission.
This command helps you to find the name to IP or IP to name in IPv4 or IPv6 and also query DNS records. Give it a domain name and you’ll see the associated IP address. Give it an IP address and you’ll see the associated domain name.
# host www.google.com.in Host www.google.com.in not found: 3(NXDOMAIN) Aashirvads-MacBook-Air:~ aashirvad$ host www.google.in www.google.in has address 22.214.171.124 www.google.in has IPv6 address 2404:6800:4008:c01::5e
It helps to trace the path of the network to the destination you have provided. It attempts to list the series of hosts through which your packets travel on their way to a given destination. Tracepath can be very handy when trying to determine the points of slowness in your connection path.
ARP (Address Resolution Protocol)
This is a is used to view/add the contents of the kernel’s ARP tables. To see default table use the command as.
# arp -e Address HWtype HWaddress Flags Mask Iface 192.168.50.1 ether 00:50:56:c0:00:08 C eth0
It is used to view, setting speed and duplex of your Network Interface Card (NIC). You can set duplex permanently in /etc/sysconfig/network-scripts/ifcfg-eth0 with ETHTOOL_OPTS variable.
# ethtool eth0 Settings for eth0: Current message level: 0x00000007 (7) Link detected: yes
# iwconfig [interface]
Run hostname command to see the hostname of your box. You can set hostname permanently in /etc/sysconfig/network. Need to reboot box once set a proper hostname.
# hostname teletrickmania
The route command is the tool used to display or modify the routeing table.
# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.50.0 * 255.255.255.0 U 0 0 0 eth0 link-local * 255.255.0.0 U 1002 0 0 eth0 default 192.168.50.1 0.0.0.0 UG 0 0 0 eth0
system-config-network – GUI Tool
Type system-config-network in command prompt to configure network setting and you will get nice Graphical User Interface (GUI) which may also use to configure IP Address, Gateway, DNS etc.
Use this command to release (-r option) your IP address and get a new one from your DHCP server. This command needs admin permission.
These are the useful and essential Linux network commands which are helpful in many cases. These commands are basic Linux network commands which help you to many things on your PC. Many of the advance commands are available for doing many tasks and getting more information about the network. Many of the commands are also helpful in MAC & Windows. You can also comment your favorite Linux network commands in the comment section below.