Network configuration in Linux : PART 1

Network configuration in Linux : PART 1


In this post i just like to share how to configure netowrk card / IP address in Linux server. Hope this will help you.


The below Points are explained,

1.Commands list hardwares in Linux?
2.How to List Network cards in Linux server?
3.Config Files for network in Linux?
4.Adding new network card on Linux server?
5.Configuring IP address for interface?
6.How to define the routing ?
7.How to activate / deactivate network interfaces ?
8.How to enable IP Forward in Linux?
9.Speed and Duplex setting for interface?
10.Usefull commands in Linux for network troubleshoot.




1. List hardware devices in linux?

    lspci : List all PCI devices.
    lshw  : List all hardware.
    dmidecode  : List all hardware data from BIOS.
    ifconfig   : Outdated network config utility.
    ip  : Recommended new network config utility.


2. List of network cards??

1.# lspci | egrep -i --color 'network|ethernet'

2.# lshw -class network

3.# ifconfig -a

4.# ip link show 0r #ip addr show

5.# cat /proc/net/dev



3. Network config files:

A. /etc/resolve.conf   : List DNS servers for internet domain name resolution.

B. /etc/hosts          : Lists hosts to be resolved locally (not by DNS)

C. /etc/nsswitch.conf  : List order of host name search. Typically look at local files, then NIS server, then DNS server.

D. /etc/sysconfig/network: Specify network configuration. eg. Static IP, DHCP, NIS, etc

E. /etc/sysconfig/network-scripts/ifcfg-device : Specify TCP network information



A. /etc/resolv.conf:

E.g of host name resolver config file entries.

More /etc/resolv.conf

search name-of-domain.com  - Name of your domain or ISP's domain if using their name server
nameserver XXX.XXX.XXX.XXX - IP address of primary name server
nameserver XXX.XXX.XXX.XXX - IP address of secondary name server


B./etc/hosts

E.G of  locally resolve node names to IP addresses . This informs Linux of local systems on the network which are not handled by the DNS server.

127.0.0.1         your-node-name.your-domain.com  localhost.localdomain  localhost
XXX.XXX.XXX.XXX   node-name

C. /etc/sysconfig/network

- Red Hat network configuration file used by the system during the boot process.

D. /etc/sysconfig/network-scripts/ifcfg-XXX - config file for network card

E.g - /etc/sysconfig/network-scripts/ifcfg-eth0

root# more ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
ONBOOT=yes
IPADDR=10.175.2.10
NETMASK=255.255.255.0
root #

E. /etc/sysconfig/network -scripts/ifcfg-ethXX

- Static IP address Configuration: (Configure gateway address)

- Entries in this files explianed below

---------------------------------------------------------
 For static IP the file should have below entries,

NETWORKING=yes
HOSTNAME=my-hostname      - Hostname is defined here and by command hostname
FORWARD_IPV4=true         - True for NAT firewall gateways and linux routers.
                            False for everyone else - desktops and servers.
GATEWAY="XXX.XXX.XXX.YYY" - Used if your network is connected to another network or the internet. Static IP configuration. Gateway not defined here for DHCP client.
---------------------------------------------------------
For DHCP client config file should have below entries

NETWORKING=yes
HOSTNAME=my-hostname      - Hostname is defined here and by command hostname

---------------------------------------------------------
 For NIS client config the file should have below entries.

NETWORKING=yes
HOSTNAME=my-hostname      - Hostname is defined here and by command hostname
NISDOMAIN=NISProject1     - NIS domain to attach

---------------------------------------------------------


4. Adding network card to Linux server?

Login to server as root and then navigate to the directory /lib/modules/ . Here you will find the modules supported by your system.
Assuming that you have a 3Com ethernet card, in which case, the module name is 3c59x ,
you have to add this in the /etc/modules.conf or /etc/modprobe.conf  file to let the machine detect the card each time the machine boots.


Add driver for ur new card  manually in /etc/modprobe.conf  (Kernel 2.6)  or etc/modules.conf (kernel 2.4)

#vi  /etc/modprobe.conf 

alias eth1 e100
alias eth2 "Driver name"    //add this line for ur eth2 network card with driver info (3c59x)

Load the module to kernel

# /sbin/insmod -v "drivername"  // 3c59x

Check the loaded netowrk card in server using below commands

Then Reboot server and check the new card status.


#lspci |grep -i ethernet

# more /etc/modprobe.conf |grep -i eth

Modprobe command line options:

    -r : to unload the module.
    /sbin/modprobe -l \*   :list all modules.
    /sbin/modprobe -lt net \*  : List only network modules
    /sbin/modprobe -t net \*   : Try loading all network modules and see.
 


 For below Points please check the part 2 :

5.Configuring IP address for interface?
6.How to define the routing ?
7.How to activate / deactivate network interfaces ?
8.How to enable IP Forward in Linux?
9.Speed and Duplex setting for interface?
10.Usefull commands in Linux for network troubleshoot.


Click here for PART 2 : Network config in Linux ?



 

Post a Comment

0 Comments