Helpdesk Support

Official Supportmonk Company Blog!

Understanding Networking in Linux

January 11, 2014 , 5:22 pm

The Linux Operating System boasts  kernel based networking support. The majority of the current distributions comes with Networking enabled. It may not be required to recompile the kernel.  A well supported hardware would be enough.  Here I would like to discuss on configuring network on your Linux machine.

Checking the connection

$ ping -c 3 google.comPING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=41 time=287 ms
64 bytes from ( icmp_req=2 ttl=41 time=287 ms
64 bytes from ( icmp_req=3 ttl=41 time=318 ms— ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2400ms
rtt min/avg/max/mdev = 287.727/297.989/318.441/14.461 ms


Note: If you receive an error like ping: icmp open socket: Operation not permitted when executing ping, try to re-install the iputils package.


Set the hostname

A hostname is a unique name created to identify a machine on a network: it is configured in /etc/hostname. The file can contain the system’s domain name, if any. To set the hostname, do:


# hostnamectl set-hostname myhostname


Check the driver status

udev should detect your network interface card (NIC) and automatically load the necessary module at start up. Check the “Ethernet controller” entry (or similar) use


$ lspci -v03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 09)

Kernel driver in use: r8169



Next, check that the driver was loaded via

$dmesg | grep module_name.

$ dmesg | grep r8169r8169 0000:03:00.0: eth2: link up


NIC Installation

In case if you need to load NIC you can follow these steps


Driver Installation(Kernel Module)

RedHat/Fedora distributions of linux ships with Kudzu a device detection program which runs during systems initialization (/etc/rc.d/init.d/kudzu).

This can detect a newly installed NIC and load the appropriate driver.

Driver Path

$ ll /lib/modules/<KERNEL VERSION>/kernel/drivers/net/


To list preloaded NIC modules

$ modprobe -lt net

To load all NIC modules

$ modprobe -t net


To get NIC details

$ lspci | grep –i ethernet03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 09)

Manual Driver installation

Loading kernel module

modprobe “module”

$ vi /etc/modprobe.confalias eth0 “module”


To check errors

#dmesg | grep –i eth0


Linux TCP/IP Network Configuration Files

Here are the set of file which you need to know to successfully configure the network on a Linux machine. They are Domain resolution configuration files and Network configuration files. Here is the list.

                     File                                                                         Description

/etc/resolve.conf                                List DNS servers for internet domain name resolution.

/etc/hosts                                               List hosts to be resolved locally (not by DNS).

/etc/sysconfig/network                    Specify network configuration eg: Static IP, DHCP, NIS etc.

/etc/network/interfaces                     Specify network config and devices eg: Static IP , DHCP etc.

/etc/nsswitch.conf                                 List order of hostname search. Typically look

                                                                       at local files, then NIS,  then DNS server.

Domain Resolution Configuration Files:

File: /etc/resolv.conf – host name resolver configuration file

nameserver XXX.XXX.XXX.XXX(

nameserver XXX.XXX.XXX.XXX(


File: /etc/hosts – locally resolve node names to IP addresses

XXX.XXX.XXX.XXX node-name

File: /etc/nsswitch.conf – System Databases and Name Service

hosts: files dns nisplus nis



Network Configuration Files:


File: /etc/sysconfig/network





File: /etc/sysconfig/network-scripts/ifcfg-eth0









Configure the IP address

You have two options: a dynamically assigned address using DHCP, or an unchanging “static” address.

Dynamic IP address

Manually run DHCP Client Daemon

$ dhcpcd eth0dhcpcd: version 5.1.1 startingdhcpcd: eth0: broadcasting for a lease

dhcpcd: eth0: leased for 86400 seconds


Run DHCP at boot

If you simply want to use DHCP for your Ethernet connection, you can use [email protected] (provided by the dhcpcd package).

To start DHCP for eth0, simply use:

$ systemctl start [email protected]



$ vi /etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0ONBOOT=yes



Static IP address assignment:


ifconfig eth0 netmask broadcast


Network IP aliasing:


$ ifconfig eth0:0 netmask broadcast


To enable/disable particular interface


ifup eth0:0ifdown eth0:0


Command Line IP configuration: ifconfig

ifconfig interace [aftype] options | address ….


  • interface: eth0, eth1, eth2 represent the computer ethernet interfaces
  • aftype: inet (TCP/IP, default), inet6 (IPv6), ax25 (AMPR Packet Radio), ddp (Appletalk Phase 2), ipx (Novell IPX) or netrom (AMPR Packet radio)



Option Description
up Activate the interface. Implied if IP addresses are specified.
down Shut down interface
arp Enable ARP protocol on this interface. Allow ARP to detect the addresses of computer hosts attached to the network.
-arp Disable ARP protocol on this interface
promisc Enable promiscuous mode. Receive all packets on the network not just those destined for this interface.
-promisc Disable promiscuous mode.
mtu ## Specify the Maximum Transfer Unit (MTU) of the interface. The MTU is the maximum number of octets the interface is able to handle in a single transaction. Defaults: Ethernet: 1500 SLIP: 296
broadcast XXX.XXX.XXX.XXX Set the network broadcast address for this interface.
netmask XXX.XXX.XXX.XXX Set the IP network mask for this interface.


To get NS, Broadcast, Subnet etc(DHCP)


$ pump -i eth0 –status


Turn on IP forwarding to allow Linux computer to act as a gateway or router.

$ vi /etc/sysctl.confnet.ipv4.ip_forward = 1sysctl –p

List routing:


$ route –n$ ip route list$ netstat –nr


Find out driver name associated driver information for eth0

$ ethtool -i eth0


To find factory-default MAC address information:

$ ethtool -P eth0



Now you should be ready with a completely configured LAN network on your Linux machine. Lets have a quick look on checking, tweaking NIC connected to your device.


To get NIC speed and other valid informations.

$ethtool eth0Settings for eth0:Supported ports: [ TP MII ]

Supported link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Supports auto-negotiation: Yes

Advertised link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

Advertised auto-negotiation: Yes

Speed: 100Mb/s

Duplex: Full

Port: MII


Transceiver: internal

Auto-negotiation: on

Supports Wake-on: pumbg

Wake-on: d

Current message level: 0x00000007 (7)

Link detected: yes

How to change NIC speed, mode of transfer etc


$ ethtool –s eth0 speed 100 duplex full autoneg on$ ethtool -s eth0 speed 100 duplex full$ ethtool –change eth0 speed 10 duplex half

$ vi /etc/sysconfig/network-scripts/ifcfg-eth0

ETHTOOL_OPTS=”speed 100 duplex full autoneg off”

Outsourced Customer Support