Showing posts with label configuration for linux network. Show all posts
Showing posts with label configuration for linux network. Show all posts

13 May, 2013

Linux Network Configuration

Here i am explaining the Linux network configuration and important network files descriptions are explained below:

>> The purpose of /etc/hosts configuration file is to resolve hostnames, there is no other way to resolve hostnames. It also resolves on small networks with no DNS server. This file contains a line specifying the IP address of the loopback device (127.0.0.1) as localhost.localdomain.

[root@linuxguideco ~]# vim /etc/hosts

sample outputs

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1          localhost.localdomain localhost
::1                    localhost6.localdomain6 localhost6
192.168.1.3      linuxguideco

>> The /etc/resolv.conf configuration file specifies the IP addresses of DNS servers and the search domain. To setup DNS servers, edit /etc/resolv.conf, enter

[root@linuxguideco ~]# vim /etc/resolv.conf

sample outputs

nameserver 8.8.8.8
nameserver 8.8.4.4
search localdomain

>> The /etc/sysconfig/network configuration file contains routing and host information for all network interfaces.

[root@linuxguideco ~]# vim /etc/sysconfig/network

sample outputs

NETWORKING=yes
NETWORKING_IPV6=no
#HOSTNAME=localhost.localdomain
HOSTNAME=linuxguideco
GATEWAY=192.168.1.1

>> Each network interface has a corresponding interface configuration script. To configure ethernet interface, edit /etc/sysconfig/network-scripts/ifcfg-eth0, enter

[root@linuxguideco /]# cd /etc/sysconfig/network-scripts

[root@linuxguideco network-scripts]# ls -la | grep ifcfg-

sample outputs

-rw-r--r--  3 root root   244 Oct 15  2010 ifcfg-eth0
-rw-r--r--  3 root root   141 Oct 15  2010 ifcfg-eth1
-rw-r--r--  1 root root   254 Oct 13  2010 ifcfg-lo

>> Edit configuration file of NIC for which you want to set a static IPs. In this example, I will configure a static IP address for eth0 and use the Internet Protocol Version 4.

[root@linuxguideco network-scripts]# vim ifcfg-eth0

sample outputs

Below sample specifies static IP configuration to set parameters below according to your settings.

# Intel Corporation 82574L Gigabit Network Connection
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.1.255
HWADDR=00:0C:29:E8:EF:34
IPADDR=192.168.1.3
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes

>> Save the configuration file and exit. To apply changes, we need to bring the network interface down and back up, type the following command

[root@linuxguideco network-scripts]# /etc/init.d/network restart

Or,

[root@linuxguideco network-scripts]# service network restart

[root@linuxguideco network-scripts]# chkconfig network on


After above steps network files will be configured successfully.


Disable IP Version 6

Disable Internet Protocol version-6 if you don't need it.

edit the configuration file /etc/sysctl.conf, enter

[root@linuxguideco network-scripts]# vim /etc/sysctl.conf

add following lines at last in the config file.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1


save / exit the file and reload it with following command.

[root@linuxguideco /]# sysctl -p


After reload IP version 6 will be disabled.