Wednesday 31 October 2012

Network Configuration

Network Configuration

Linux is a perfect networking operating system. It is highly secure if handled carefully. We can handle network of linux operating system in two ways:

1. Static IP allocation.

2. NetworkManager IP allocation.

3. Bridge Configuration.


We will learn above the methods one by one.

1. Static IP allocation:

Now open the file:

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

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.168.0.12
NETMASK=255.255.255.0
GATEWAY= 192.168.0.1

save the file and quit. Make sure that you know the gateway address. Don't forget to restart the network service, It is necessary to restart the service so that new settings take place.

# /etc/init.d/network restart

Using this technique we can assign IP address permanently to a machine. We can also assign temporary IP as below:

# ifconfig eth0 10.14.153.45 netmask 255.255.255.0

This will temporarily set the IP address to given above, also we have to specify the interface on which we are giving the IP address. We can also bring down or bring up the interfaces manually using the below commands:

# ifup eth0
#ifdown eth0

2. Dynamic IP allocation:

Open the file:

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

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=dhcp
NM_CONTROLLED=yes

save the file and quit.

In this case restart the service of networkmanager as:
# /etc/init.d/NetworkManager restart
However, If the network is not managed yet, check for the following:

1. Check for the network cable, may be there is no cable.
2. Check for the interface on which cable is plugged, i.e. there may be two ethernet cards. In case you have two ethernet cards, run the command as:

# ethtool eth0
# ethtool eth1
# mii-tool

The above commands shows if the link is present or not.

3. In case, if link is not present, check your cable. It may be broken.

3. Network configuration for bridged network.

Stop the service of networkmanager as;

# /etc/init.d/NetworkManager stop;chkconfig NetworkManager off

Now edit the file ifcfg-br0 as;

# vim /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
GATEWAY=192.168.100.1
IPADDR=192.168.100.32
NETMASK=255.255.255.0
ONBOOT= yes
Now open the file ifcfg-eth0 as;

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

DEVICE=eth0
ONBOOT=yes
TYPE=Ethernet
BRIDGE=Bridge

Don't forget to restart the service of network as;

# /etc/init.d/network restart

No comments:

Post a Comment