Thursday, December 22, 2011

Basic Network Configuration of Linux System

Main configuration files

  • /etc/hostname : contains name of host machine ; give the hostname in this file to permanently change the hostname. Otherwise, use "hostname" command to change the hostname temporarily

#hostname client1.ciscofriend.comLinux Basic Networking

  • /etc/hosts : Contains Name to IP mapping in the local system
  • /etc/resolv.conf : Contains address of DNS servers
  • /etc/nsswitch.conf : Determines order in which name resolution take place in system. We can change the order in this file  to configure  system to check first DNS then host file etc.

Redhat Network Files

  • /etc/sysconfig/networks-scripts/ifcfg-eth0 : IP address information stored here
  • /etc/sysconfig/network : This file contains the hostname; but this is a non standard way, Ubuntu/Debain is using the correct way

Debian/Ubuntu Network files

  • /etc/network/interfaces

Commands to configure network

  • Ifconfig : dipsplay and configure network interfaces

#ifconfig eth0 192.168.1.22  (set the IP of Ethernet 0 interface to 192.168.1.22)

#ifconfig eth0 netmask 255.255.255.0  (set the subnet mask)

#ifconfig eth0 hw ether 00:00:00:00:00:11 (To change the MAC address of eth0 interface)

#route add default gw 192.168.1.1  (To change the default gateway)

  • Ifup : configure and activate network interface based on config files

#ifup eth0

  • Ifdown- disable configured network interfaces

#ifdown eth0

No comments: