Related

Linux Netwoking commands Part 1

Networking allows us to exchange data between computers. In a computer network more than one computers are connected to each other to share information. I am assuming that you already know the networking basics.

In this article we will go through essential Linux networking commands.

In order to make effective use of server it is essential for Linux administrator to know the list of networking commands.

In this article we will go through most frequently used commands.Open you terminal.

hostname

host name command is used to know the hostname or simply your computer name.

root@seven:~# hostname

hostname -i

It returns your local host's address.

root@seven:~# hostname -i
127.0.1.1

ping

Ping is used to identify whether a host is alive or not.it sends icmp packets to the specified host.If packets are not received back or does not respond then there is something wrong. See the below statistics there is no packet loss that means google is up and running perfectly.

root@seven:~# ping www.google.com
--- google.com ping statistics ---
116 packets transmitted, 115 received, 0% packet loss, time 115136ms
rtt min/avg/max/mdev = 84.929/310.674/1033.742/152.392 ms, pipe 2

netstat

Netsat is a very versatile command.It is used to network connection,open sockets,routing tables and interface statistics.

root@seven:~# netstat

traceroute

Traceroute is similar to ping.Traceroute also uses icmp packets.But it returns a lot of information like route path also calculates transit delay of packets and number of hops.

root@seven:~# ping google.com
PING google.com (216.58.197.46) 56(84) bytes of data.
64 bytes from maa03s20-in-f14.1e100.net (216.58.197.46): icmp_seq=1 ttl=128 time=439 ms
64 bytes from maa03s20-in-f14.1e100.net (216.58.197.46): icmp_seq=2 ttl=128 time=359 ms
64 bytes from maa03s20-in-f14.1e100.net (216.58.197.46): icmp_seq=3 ttl=128 time=349 ms

whois

whois gives you information regarding domain name.It displays information like domain ownership ,registration date ,sub-domains,ip addresses etc.It gives you all the public information about the domain.

root@seven:~# whois google.com
   IP Address: 211.64.175.67
   IP Address: 211.64.175.66
   Registrar: GODADDY.COM, LLC
   Whois Server: whois.godaddy.com
   Referral URL: http://registrar.godaddy.com

   Server Name: GOOGLE.COM.SPROSIUYANDEKSA.RU
   Registrar: MELBOURNE IT, LTD. D/B/A INTERNET NAMES WORLDWIDE
   Whois Server: whois.melbourneit.com
   Referral URL: http://www.melbourneit.com

ifconfig

ifconfig allows us to view and configure our network interfaces.ifconfig displays all the network information like ipaddress netmask etc.ifconfig displays all the network cards like eho0(ethernet),wlan(wireless) connected to your computers.

root@seven:~# ifconfig
		inet 192.168.150.130  netmask 255.255.255.0  broadcast 192.168.150.255
        inet6 fe80::20c:29ff:fed5:201a  prefixlen 64  scopeid 0x20
        ether 00:0c:29:d5:20:1a  txqueuelen 1000  (Ethernet)
        RX packets 320  bytes 49885 (48.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 410  bytes 38715 (37.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
		inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 
        loop  txqueuelen 0  (Local Loopback)
        RX packets 24  bytes 1440 (1.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 24  bytes 1440 (1.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ifconfig -a

It displays all the active interfaces.

root@seven:~# ifconfig -a

Display specific interface

If you want to see the specific interface then follow the below syntax.

root@seven:~# ifconfig eth0
eth0:  mtu 1500
        inet 192.168.150.130  netmask 255.255.255.0  broadcast 192.168.150.255
        inet6 fe80::20c:29ff:fed5:201a  prefixlen 64  scopeid 0x20
        ether 00:0c:29:d5:20:1a  txqueuelen 1000  (Ethernet)
        RX packets 324  bytes 50783 (49.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 412  bytes 39117 (38.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Bring interface down

Interface can be disabled with the following command.If you want to bring down wireless interface down just write wlan0 after ifconfig.

root@seven:~# ifconfig eth0 down

Enable interface

root@seven:~# ifconfig eth0 down