Basic Linux Networking

After installing a linux server and playing with the basic command lines, the first thing we should be able to do is configure our network, without which of course there is no Internet. Most of the latest linux distributions ship with easy to use GUI for configuration and testing of the network. But here we’ll be using all command lines. Remember, these commands directly talk to the responsible programs without any intermediary (GUI), so obviously it’s fast, more powerful and have many options that are not available in GUI.

This guide will help you to configure your network and troubleshoot simple network problems using command lines.

This command is used to configure or view the information of network interfaces. E.g. if you want to configure the interface eth0 with an ip address, you should use the following command:

The other useful and simple use of ifconfig is done with the switch -a, which displays the state of all the interfaces. It lists all the informations you need to know about your network card. In the following example you can see Hardware Address (Hwaddr), IP Address (inet addr), Broadcast Address (Bcast), Subnetmask (Mask) and many more.


The second thing we need to configure after the ip address is default route or gateway. The following command will add a default gateway, which is accessible via interface eth0.
The default gateway can be deleted just by substituting the add with del in the above command.

You can check the default gateway and the whole routing table by executing simple route command.


After setting up the ip address and the default gateway, final thing you need do is configure the DNS servers. The DNS server information is stored in a text file /etc/resolv.conf. You can use your favourite text editor (e.g. vi or emacs) to edit the file. Following is a sample resolv.conf file, where two (primary and secondary) DNS servers are listed:


That’s it, congratulations! You’ve configured the network of a linux server, which should allow to go to the Internet.
Sooner or later you’ll either need to check simple connectivity issues or troubleshoot serious network problems. Here are some very useful and basic diagnostic commands that can help you along the way.

I think ping is one of the most useful and widely used commands to check network connectivity. This command is used to test whether a particular host is rechable over an IP network. Ping uses ICMP packets to send an “echo request”, and the receiving host is required to answer back using “echo reply”. If you cannot reach the internet, the first thing you should do is ping your default gateway to make sure that you get an icmp reply.


While ping helps to check the connectivity between two hosts, traceroute actually show the route between them. It lists the nodes (hosts/routers) that your packet will travel through to reach the destination. If the ping shows some packet loss, looking at the output of traceroute we can figure out which hosts (routers) along the way have problems. This can be determined looking at the latency at each host. From the following traceroute we can see that to reach Google, the packet needs to travel through 5 hops (hosts/routers).

This command is very useful when you want to see where your server is connected to and also who is connected back to your server and services from outside. netstat prints the active network connections, routing tables, interface statistics, masquerade connections, and multiĀ­cast memberships. E.g. when it’s invoked with the switch -a, it lists all the active network connections and services that this server is listening to.

This command is used to test DNS servers and domain names. E.g when executed with switch -q=any, it provides the ip address of the domain name we’re querying about, the name servers responsible for this domain and other parameters such as TTL and contact email address of the administrator.

Be Sociable, Share!
Posted in Admin, HowTo, Linux/Unix, Network, Technology
0 comments on “Basic Linux Networking
1 Pings/Trackbacks for "Basic Linux Networking"
  1. Your Most Powerful Network Marketing Tool…

    The internet is full of millions of self replicated websites, and if you’re a Network Marketer you probably have one too! So how do YOU get noticed in this sea of duplicated websites?? Well to be absolutely truthful you do not! Have you noticed that p…

Leave a Reply

Your email address will not be published. Required fields are marked *


Recent Comments

Muhammad Ali on Meeting Buddha Boy: I am really moved by seeing a…(January 16, 2018, 4:43 pm)
LastMarina on How I Prepared and Passed CISSP : I see you don’t monetize your site,…(January 11, 2018, 5:20 pm)
FirstCandace on WinXP and OSX dual boot in MacBook Pro: I have noticed you don’t monetize your…(November 10, 2017, 11:32 pm)
From Wikipedia, the free encyclopedia – Ram Bahadur Bomjon on Buddha Boy attacked and injured a guy with his sword?: […] Niranjan (July 20, 2007). “Buddha Boy…(September 2, 2017, 5:07 pm)
Micle on How I Prepared and Passed CISSP : Nice Aritcle…(August 10, 2017, 8:51 am)