Network Configuration
Linux System Recognize the Network devices eth0, eth1 etc for First Ethernet card, tr0, tr1 etc for Token Ring and fddi0, fddi1 etc for FDDI Interface.
/etc/sysconfig/network file is called the global network configuration file contains global parameter for network configuration.
- [root@mann ~]# cat /etc/sysconfig/network
- NETWORKING=yes
- HOSTNAME=mann.home
- GATEWAY=X.X.X.X
- [root@mann ~]#
To enable the network on you system value of NETWORKING should be yes. Some services are dependable on this parameter, which required NETWORKING=yes. There is hostname command, which prints or set the host name for current session but to set the host name permanently on your system, you should specify the hostname in HOSTNAME=parameter. GATEWAY parameter defines the global default gateway.
/etc/sysconfig/network-scripts/ifcfg-eth? File is called the interface specific file use to configure the specific
interface. Generally interface specific file contains following parameters:
- [root@mann ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
- DEVICE=”eth0″
- BOOTPROTO=none
- NM_CONTROLLED=”yes”
- ONBOOT=”yes”
- HWADDR=00:0C:29:97:E6:07
- MTU=1500
- TYPE=Ethernet
- IPADDR=192.168.0.30
- PREFIX=24
- DEFROUTE=yes
- IPV4_FAILURE_FATAL=yes
- IPV6INIT=no
- NAME=”System eth0″
- UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
Device parameter define the device name of configuration that is same as ifcfg-eth?. Onboot parameter defines whether bring up interface automatically at boot time or not. If you set yes, it will enable the Interface at boot
time otherwise you should manually start the interface. Bootproto define the boot protocol either static or dhcp.
If you use static, you should assign the IP Address, Subnet mask manually and if you set dhcp, ip address, netmask and
other information will assign by DHCP server. GATEWAY is the interface specific Gateway parameter, which overrides
the global gateway parameter.
#ifconfig : Command used to display the information about interface connected into the system.
[root@mann ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:29:97:E6:07
inet addr:192.168.0.30 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe97:e607/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:10353 errors:0 dropped:0 overruns:0 frame:0
TX packets:8159 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:880387 (859.7 KiB) TX bytes:1807052 (1.7 MiB)
Interrupt:19 Base address:0x2024
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:446 (446.0 b) TX bytes:446 (446.0 b)
[root@mann ~]#
# ifdown eth0 : Which downs the interface
# ifup eth0 : which brings up the interface
Whenever you change the configuration of /etc/sysconfig/network file, you should restart the network
service. Similarly after changing the configuration of interface should down and up once.
Assigning Multiple IP Address on Interface For Routing you can assign multiple IP Addresses on same
Interface. On One Physical Interface we can assign upto 256 IP Addresses.
# vi /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.55
NETMASK=255.255.255.0
[root@localhost network-scripts]#
For bringing down the interface
# ifdown eth0
For bringing up the interface
#ifup eth0
The other important topic is route in terms of linux networking .To know more how to add/delete route click below link.
To Know all the topics related to LINUX please click below link.