Basic Network Configuration in Linux

Basic Network Configuration:

Networks are two types

1. IPv4
2. IPv6


What is IP Address : 

Every computer on network requires an IP address to communicate with other computer. Linux is developed for networking. To pass RHCE exam you must understand networking.

An IP is a 32-bit number comprised of a host number and a network prefix, both of which are used to uniquely identify each node within a network.

To make these addresses more readable, they are broken up into 4 bytes, or octets, where any 2 bytes are separated by a period. This is commonly referred to as dotted decimal notation.

The first part of an Internet address identifies the network on which the host resides, while the second part identifies the particular host on the given network. This creates the two-level addressing hierarchy.

All hosts on a given network share the same network prefix but must have a unique host number. Similarly, any two hosts on different networks must have different network prefixes but may have the same host number.

Here is a simple example of an IP address: 192.168.1.1

An additional value, called a subnet mask, determines the boundary between the network and host components of an address.

Subnet masks are 32 bits long and are typically represented in dotted-decimal (such as 255.255.255.0) or the number of networking bits (such as /24). The networking bits in a mask must be contiguous and the host bits in the subnet mask must be contiguous. 255.0.255.0 is an invalid mask. A subnet mask is used to mask a portion of the IP address, so that TCP/IP can tell the difference between the network ID and the host ID. TCP/IP uses the subnet mask to determine whether the destination is on a local or remote network.

Stages of IP Address :
 Class A addresses range from 1-126  

  Class B addresses range from 128-191  

 Class C addresses range from 192-223  
 Class D addresses range from 224-239  
 Class E addresses range from 240-254  
 0 is reserved and represents all IP addresses;  
 127 is a reserved address and is used for loop back tasting:  
 255 is a reserved address and is used for broadcasting purposes.  

Assign IP Address in Linux : (RHEL 6)
To set up a network we need following parameters

1. IP Address
2. Subnet Mask
3. Gateway
4. DNS Server

In RHEL you can assign these parameters in two ways.

     1. Static configuration

     2. Dynamic configuration

Static configuration :
In static configuration you have to assign all these parameters manually. Static configuration does not change automatically. Static configuration generally used with servers or network resources like printer, router etc. Static configuration uses set parameters for the configuration, which is known by the system and the network.

Dynamic configuration :
Dynamic configurations are handled by DHCP server. In dynamic configuration DHCP service on the network provides all these parameters to a system when it joins the network.

Dynamic configuration generally used with workstations. Dynamic configuration configures network parameters on the boot.

Red Hat provides two tools to configure the network device.

We can Assign IP Address to a system through

1. Command Line 

2. Editing Configuration Files

Command Line : (Semi Graphical)
This is a command line network configuration tool. Use this tool to configure IP address on console. This tool can be invoked by running system-config-network command.


 #system-config-network  


Network Manager Window is opened. Now press Enter to Go to the Options


On Select A Device screen select first network card (eth0) and press ENTER



Now we are on Network configuration screen. As we mentions above IP configuration can be set in two ways static or dynamic.

To set IP configuration dynamically Select DHCP


To use static IP configuration press TAB key to highlight DHCP option and press SPACEBAR to deselect it. Fill necessary parameters and select Ok by pressing TAB key. Once OK is highlighted press ENTER


Select Save by pressing TAB key and press ENTER


Select Save & Quit by pressing TAB key and press ENTER


To put the configuration customized with this tool into effect we need to reactivate the associated device. Until we reactivate associated device it would run with old configuration. You can check it with ifconfig command.


Use ifdown command to deactivate and ifup to activate.


Check again with ifconfig command. The configuration of the network card should reflect the new configuration.


Editing Configuration Files : 
We can configure network settings by editing the configuration files stored in /etc/sysconfig/network-scripts

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

Now enter all the fields like BOOTPROTO, IPADDR, NETMASK, ONBOOT etc

 # eth0 - Intel Corporation 82573E Gigabit Ethernet Controller (Copper)
 on server1.cyberciti.biz by nixCraft on 10/4/2007  
 DEVICE=eth0  
 BOOTPROTO=static  
 DHCPCLASS=  
 HWADDR=00:30:48:56:A6:2E  
 IPADDR=10.10.29.66  
 NETMASK=255.255.255.192  
 ONBOOT=yes  

and then save the file and close

Setting Default Gateway and Hostname :
You can set the hostname in the command line also.
To see the hostname use the following command

 #hostname  

To change the hostname use the following command

 #hostname myserver  

To assign default gateway and hostname we need to define them in the /etc/sysconfig/network file

 #vi /etc/sysconfig/network  

Then modify the below fields

 NETWORKING=yes  
 HOSTNAME=localhost.localadmin  
 GATEWAY=10.10.29.65  

Save the File. Finally you need to restart the network service with the below command

 # /etc/init.d/network restart  

Setting DNS Server :
Edit DNS Server details in /etc/resolv.conf file

 #vi /etc/resolv.conf  

Add the DNS server ip addresses to the /etc/resolv.conf filw

 nameserver 127.2.52.80  
 nameserver 10.52.78.54  
 nameserver 198.0.2.45  

Save and close the file.

After completing all these setup test it whether it is correctly configured or not

 # ping 127.2.52.80  

Output Will be like below

 PING 127.2.52.80 (127.2.52.80) 56(84) bytes of data.  
 64 bytes from 127.2.52.80: icmp_seq=1 ttl=251 time=0.972 ms  
 64 bytes from 127.2.52.80: icmp_seq=2 ttl=251 time=1.11 ms  


If You Enjoyed This Post Please Take 5 Seconds To Share It.

0 comments: