HowTo Red Hat Enterprise Linux 5 Configure The Network Card

Posted on in Categories , , , last updated October 19, 2013

I have installed Red Hat enterprise Linux version 5.x server. Next, I added a brand new LAN card (NIC). I can see my second network card detected while booting the IBM server. How do I configure the network card from the command line?

Red hat Enterprise Linux version 5.x and 4.x provides the following tools to make changes to network configuration such as add new card, assign/change IP address/subnet/gateway, and change DNS server and more.

[a] GUI tool – system-config-network

[b] Command line text based GUI tool (No X Windows/Gnome/KDE required) – system-config-network

[c] Edit configuration files stored in /etc/sysconfig/network-scripts/ directory. This method works with remote server over the ssh based session.

The following instructions are tested and compatible with:

  1. Cent OS Linux v3/4/5.x.
  2. Fedora Core Linux (older version).
  3. Red Hat Enterprise Linux (RHEL) v3/4/5.x based server.

Note: If you are using Debian or Ubuntu Linux, please see this configuration guide for more information.

Method # 1: GUI tool system-config-network

Open the X terminal or login using ssh over X based session command (ssh -X [email protected]). Type the following command at shell prompt:

Warning: It is important that you configure network interface cards correctly over ssh -X based session; otherwise, you will be locked out due to wrong network configuration.

$ system-config-network &
Sample outputs:

Fig.01: Configuring the RHEL/CentOS server network card using GUI tool
Fig.01: Configuring the RHEL/CentOS server network card using GUI tool

You will see a Window as above. Next, select your Ethernet card (such as eth0 or eth1) and click on the Edit button. You can now setup/modify IP address, netmask, default gateway and other properties. Here is an example from my personal RHEL 5.x server:

Fig.02: Setting or modifying IPv4 and IPv6 properties on RHEL/CentOS based server
Fig.02: Setting or modifying IPv4 and IPv6 properties on RHEL/CentOS based server

You can obtain IP address using DHCP or setup manually. Once IP address assigned, click on Ok button to save the changes. You can activate card by clicking on Activate button.

Method # 2: Command line tool system-config-network-tui

If you don’t have X windows GUI (gnome/kde desktop) installed on RHEL/CentOS/Fedora based system, than type the following command at shell prompt (this method also works on remote server using ssh based session):

Warning: It is important that you configure network interface cards correctly over ssh based session; otherwise, you will be locked out due to wrong network configuration.

# system-config-network-tui &
Sample outputs:

Fig.03: RHEL/CentOS command line network config tool (click to large)
Fig.03: RHEL/CentOS command line network config tool (click to large)

Select your Ethernet card such as eth0 or eth1 and hit [Enter] or [F12] special key to configure IP properties for selected NIC:

Fig.04: Setting up IPv4 properties on RHEL/CentOS (click to large)
Fig.04: Setting up IPv4 properties on RHEL/CentOS (click to large)

You can obtain an IP address using DHCP or setup IP address manually. Once an IP address assigned, click on the Ok button to save the changes.

Method #3: Edit configuration files stored in /etc/sysconfig/network-scripts/ directory

You can configure network card by editing text files stored in /etc/sysconfig/network-scripts/ directory. Open the terminal or login using ssh. Next, change directory to /etc/sysconfig/network-scripts/:
# cd /etc/sysconfig/network-scripts/
You need to edit / create files as follows using a text editor such as vi:

  • /etc/sysconfig/network-scripts/ifcfg-eth0 : First Ethernet card configuration file.
  • /etc/sysconfig/network-scripts/ifcfg-eth1 : Second Ethernet card configuration file.

Examples: Edit eth0 configuration file

To edit/create first NIC file, type the following command in /etc/sysconfig/network-scripts/ directory:

Warning: It is important that you configure network interface cards correctly over ssh based session; otherwise, you will be locked out due to wrong network configuration.

# vi ifcfg-eth0
OR
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Edit or modify as follows for static ip configuration:

# eth0 - Intel Corporation 82573E Gigabit Ethernet Controller (Copper) on server1.cyberciti.biz by nixCraft on 10/4/2007
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=00:30:48:56:A6:2E
IPADDR=10.10.29.66
NETMASK=255.255.255.192
ONBOOT=yes

Save and close the file.

Setting up default gateway and server (host) name

You need to define a default gateway (router IP) and hostname in /etc/sysconfig/network file. Edit /etc/sysconfig/network, enter:
# vi /etc/sysconfig/network
Append or modify configuration as follows:

NETWORKING=yes
HOSTNAME=www1.nixcraft.in
GATEWAY=10.10.29.65

Save and close the file. Finally, you need to restart the network service, run:
# /etc/init.d/network restart
OR
# /sbin/service network restart

Setting up dns server

Make sure you have correct DNS server defined in /etc/resolv.conf file:
# vi /etc/resolv.conf
Setup DNS server IP address as follows (feel free to replace 10.0.80.11, 10.0.80.12 as per your setup):
nameserver 10.0.80.11
nameserver 10.0.80.12
nameserver 202.67.222.222

Save and close the file. Now you can ping the gateway/other hosts using the ping command:
$ ping 10.0.80.12
Sample outputs:

PING 10.0.80.12 (10.0.80.12) 56(84) bytes of data.
64 bytes from 10.0.80.12: icmp_seq=1 ttl=251 time=0.972 ms
64 bytes from 10.0.80.12: icmp_seq=2 ttl=251 time=1.11 ms

You can also check for Internet connectivity with the ping, nslookup and/or host command:
$ nslookup cyberciti.biz
Sample outputs:

Server:         10.0.80.11
Address:        10.0.80.11#53

Non-authoritative answer:
Name:   cyberciti.biz
Address: 75.126.43.232

You can also use host dns lookup command as follows:
$ host nixcraft.in
Sample outputs:

nixcraft.in has address 75.126.43.232
nixcraft.in mail is handled by 10 mail.nixcraft.in.

How do I see or debug network configuration on RHEL/CentOS based server?

Simply use any one of the following commands:

###########################
## display ip config     ##
###########################
ifconfig
ifconfig -a | more
ifconfig eth0
ifconfig eth1
ip link 
ip addr
 
###########################
## display routing table ##
###########################
route 
route -nr
route -nr|more
ip route 
 
###########################
## display dns config    ##
###########################
cat /etc/resolv.conf
 
###########################
## display firewall config#
###########################
iptables -L -n -v | more
cat /etc/sysconfig/iptables
 
###########################
## Debug network issues   #
###########################
ping host-name-here
ping ip-addeess-here
host ip-address-here
host domain-name-here
traceroute host-name-here
mtr host-name-here
dmesg | grep eth
lspci  | grep -i eth
See also

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

98 comment

  1. how to configure master and slave dnd server in redhat version 5 and understanding if each and every file in configuration of dns.

    Diffrent types of dns available
    Kindly send the reply of this on my mail id

  2. Hey, somone chomped down on the text for the commandline tool and listed it as system-config-network, when it should be system-config-network-tui.

    All is explained farther down but for those thhat only read what they want, you oughta fix this.

  3. im facing problem of editing eth0 by command promt. i had tried ifcfg-eth0 command but its not saving error message is geeting on when i save that script. overrite error message getting. i had tried manny times but still its getting error message. after compliting the script for saving i esc and then shift+zz but its not saving. can u help me out of this problem.

  4. I have install Redhat linux in my pc as dual OS with Windows XP.I am using Intel DG31PR motherboard and core 2 duo processore. I am not finding any Lan card in linux os. I also insert a D-Ling gigavit ethernet card. first time i got but after changing the hard ware address of the d-link lan this is also disapeared from linux os. please give me the solutions

    Thanks
    Mahmud

  5. Hi ,

    I have installed RHEL 5 , in a DELL PC which was a fresh hardware with out any OS . Now , am facing an issue with configuring my network interface.

    While intalling the same I didn’t get an option. Now when I try thru system config network , am not able to enable the same . Am getting some error. Not remember what was the error poped up.

    Has any one faced this issue. ..?

    What could be the reason..? . How can I configure the NIC now.

    Any help is appreciated.

    1. first u have to do

      1. system-config-network
      2. there dialouge box appear
      3. select ur eth 0 card
      4. prees ok
      5. there again dialouge box
      6. give ip addrees
      7.press ok
      8. on cmd mode u have to write
      service network restart
      ur ip configured

  6. Hi,

    I’m trying to configure my dns master server but it prompts me with errors.I would appreciate if you could kindly help me with the troubleshooting.Given below is the error i received and the files i have configured. Thanks.

    starting named:
    Error in named configuration:
    zone p0725763.com/IN: loaded serial 2005071101
    zone 0.0.10.in-addr.arpa/IN: loaded serial 1997022700
    p0725763_rev:2: SOA record not at top of zone (0.0.10.in-addr.arpa)
    zone 0.10.in-addr.arpa/IN: loading master file p0725763_rev: not at top of zone
    _default/0.10.in-addr.arpa/IN: not at top of zone

    ……………………………………………………………..
    These are the files i configured.

    /var/named/chroot/etc/named.conf

    options {
    directory “/var/named”;
    dump-file “/var/named/data/cache_dump.db”;
    statistics-file “/var/named/data/named_stats.txt”;
    forwarders { 10.0.0.254; };
    };

    // for forward lookup

    zone “xxxxx.com” IN {
    type master;
    file “xxxxx_for”;
    allow-update { none; };
    };

    // for backward lookup(for network address 10.0.0)

    zone “0.0.10.in-addr.arpa” IN {
    type master;
    file “xxxxx_rev”;
    allow-update { none; };
    };

    // for backward lookup(for network address 10.0)

    zone “0.10.in-addr.arpa” IN {
    type master;
    file “xxxxx_rev”;
    allow-update { none; };
    };
    ………………………………………………………..

    /var/named/chroot/var/named/xxxxx_for

    $TTL 86400
    @ 7200 IN SOA xxxxx.com. root.xxxxx.com. (

    2005071101 ; Serial
    10800 ; Refresh
    3600 ; Retry
    604800 ; Expire
    7200 ) ; Minimum

    @ IN NS ns.xxxxx.com.
    @ IN A 10.0.0.1
    ns.xxxxx.com. IN A 10.0.0.1
    ns.xxxxx.com. IN A 10.0.0.2
    www IN CNAME xxxxx.com.

    ………………………………………………………..

    /var/named/chroot/var/named/xxxxx_rev

    $TTL 86400
    0.0.10.in-addr.arpa. IN SOA xxxxx.com. admin.xxxxx.com. (
    1997022700 ; Serial
    28800 ; Refresh
    14400 ; Retry
    3600000 ; Expire
    86400 ) ; Minimum
    0.0.10.in-addr.arpa. IN NS ns.xxxxx.com.
    5 IN PTR xxxxx.com.

  7. i am using linux system but couldnt able to assign the ip address on it. and if assigned ip address it couldnot able to activate ..message shows that wrong device ethernet card name..so how can i find out the ethernet card device details from my system

  8. i am installed the redhat enterprice linux 5.1 and i could not see the network card (NIC) in my computer (administration->network). i am reinstalled the system and again the nic card not showing. please give me an answer.

  9. I had similar problems with the RTL8168/8111 NIC card. There is no driver for this NIC in Red Hat Enterprise Linux 5.1. You will need to install 5.3 or later to get the driver.

    Even now, I still have problems with this NIC card. e.g. when sending a large file, I see that data is transferred for maybe 10 seconds at a time, followed by maybe 20 or 30 seconds of no activity, followed by further data transfer.

    In the end, I installed a different network card and configured this as eth0 and now, no problems.

  10. i am using linux red het 4,when i check ip by
    # ifconfig
    lo Link encap:Local loopback
    inet addr:127.0.0.0 mask:255.0.0.0
    inet6 addr: ::1/128 Scope : Host
    UP LOOOPBACK RUNNING MTO:16436 Metric:1
    RX Packets:1304 error :0 dropped overrun:0 frame:0
    TX packets:1304 error:0 dropped:0 overruns:0 carrier:0

    i want to change ip address 127.0.0.1 to 10.131.90.1
    how to possible that pls help me

  11. Whoops! In section 3, you forgot about editing /etc/hosts. I believe RedHat comes complete with the system’s host ip address set up in /etc/hosts. Don’t forget to give it a look.

  12. 1)whether the file exists.
    2)is the file readable.

    3)is the file writable
    4)is the file executable

    5)is the file a directory.

    please output linux red hat 5 please coding.

  13. vi editor so create file .thats may be file save command is :wq so c programming code in that write but which is the output command please
    for example :
    # vi abhay
    #cat abhay

    }
    hi helloo
    {

    save
    :wq
    in this file only save
    but output command please

  14. Hi I’m currently running cent-os 4.8 w/ vmware so I don’t know if this applies to a native install of the os or is just a bug in vmware, but in any case running ‘system-config-network-tui &’ , backgrounding the program will crash the program (the all familiar terminal goes wacky, gotta ctl-l it) but running it without the background ‘&’ symbol, all runs fine. Just putting it out there in case it helps anyone else. Great article by the way, cheers!

  15. I have installed linux redhat 9 on pcso now i want to configure samba so i connect linux to xp laptop with cross cable and given both laptop c class ip but what happend from linux pc not getting ping but xp getting ping .
    Pls help me to come out this issue .

  16. hi friends I am having my dell 1545 with Recovery and windows vista
    I want to install RHES 5 .
    I want to make Attach server with 5 others computers without DNS configuration means only local area connections .
    But I want the to use internet is when i need on only server. what would i have to do . any one help me regarding this full setup with RHES 5..

  17. I typed vi etc/hosts
    I get a window after that. I dont know how to edit. How to check what is the ip address? I am not expert in redhat. Why my command mode has $ prompt? How can I get # prompt once my redhat start? Deepak, can I chat with you through googletalk?

  18. i am using linux system but couldnt able to assign the ip address on it. and if assigned ip address it couldnot able to activate ..message shows that wrong device ethernet card name..so how can i find out the ethernet card device details from my system……

    1. Hi,

      May be your LAN is not working.

      Procedure:

      In GUI:

      1. Open console->type neat->hit enter->select ethernet card->give ip->then click ok->if it is unable to configure it, then replace your LAN.

      Or if it is ok, but LAN is still down:
      run this command0–> ifup eth0 (eth0 is your ethernet name)

      ot you can give ip in the configuration file.

    2. First check if how many Network card Interface installed in your computer.
      LINUX OS read the NIC card as eth0 represents your first device name network Interface, now if you have so many Network cards, the Linux read your device as eth1 or eth2 etc.. but need to configure later,

      if you want to configure your first network interface card eth0? open your terminal or linux console, edit your system network config. type this command in your terminal vi /etc/sysconfig/network-scripts/ifcfg-eth0
      then change your address and BOOTPRO=static

      im a newbie but i understand what i am writing right now, this article is great..make it simple not the other comments here there are so many reply but people who need helps didn’t understand because of pretenders

  19. i am using linux system but couldnt able to assign the ip address on it. and if assigned ip address it couldnot able to activate ..message shows that wrong device ethernet card name..so how can i find out the ethernet card device details from my system……

    1. Hi Saurav,

      Give the ip in the configuration file, and then restart the network service.

      Then check whether the ip assigned to it or not.

      Otherwise, it means your ethernet card is not working.

    2. Hi Saurav,
      when you do ifconfig..what you see ?
      1. To find the driver details:
      At the shell, type :
      a) lspci | grep Ethernet
      b) dmesg | grep ‘eth0’
      2. Once you know the type of card, take a look at /lib/modules/kernelver/kernel/drivers/net and see if you can identify the required driver. For example, if your eth0 device is an Intel PRO/1000 card, you would add the following line to your /etc/modprobe.conf file: alias eth0 e1000 (Again depends what type of card you have).
      3. what is the output of this cmd :cat /etc/sysconfig/network-scripts/ifcfg-eth0

  20. hello my dear i want do configuration and other things as follow in steps
    1-different between server and client
    2-how to give server permission to client
    3-how i know ip address
    4-how i shutdown client from server
    5- how i install software both in client an server in same time
    6-steps of share files
    7-how i send message to client from server

  21. sorry my dear
    question as follow?
    how i can recognize different between client and server?
    how i can shut down client from server?
    how i can share file between client and server?
    how i can installation software both in server and client?

  22. Redhat’s archaic and ineffective methods of managing NICs are yet one more reason why you should never ever use Redhat for anything. God forbid you install an OS and shit just works. Redhat is where Linux gets it’s bad rep from.

  23. How the conflicts in the IP address and systemname will be resolved.Coz I got to know that two systems can take same name which will lead to conflict.Please let me know how this is handled.

  24. hello,
    am using a dell laptop, i have installed redhat 6 and am trying to configure network settings. please guide me on how to go about it. i have made my machine a dual boot. tell me how i can make ntfs files viewable in redhat?. am new in using redhat

  25. Hello ! Very useful site. I have a linux rhel5 server with an application software being used by more than two persons at a time through lan. I wish to make this server as a web server also, so that other people can access my website on this server. At the same time, my users working with the application software/server through client SHOULD NOT be able to acces the internet. Please provide instructions.

  26. Hello ! Very useful site. I have a linux rhel5 server with an application software being used by more than two persons at a time through lan. I wish to make this server as a web server also, so that other people can access my website on this server. At the same time, my users working with the application software/server through client SHOULD NOT be able to acces the internet. Please provide instructions.

  27. dear i have installed RHEL 5 in Acer mini net book lan and wifi drivers are not installed atleast those devices are not detecting or showing in network config’s please any body help me .,

  28. Hi
    I have installed Redhat Linux 6.0 in my laptop.
    Now I want to configure the internet connection. I have airtel broadband wired connection.
    I don’t know why I m not getting the resolv.conf in my system.
    When I m giving the “ifconfig” command it is showing the lo ie the loopback address 127.0.0.1.
    Unfortunately I m not getting any eth0 to configure the net connection.
    Please help me to resolve the problem.

  29. Hi please I installed RHEL 6.1 on a dell r720 server, I tried the system-config-network command but in the device configuration interface, I cannot find anything it is just blank.
    Please help as my server is suppose to go love today but this issue is making look like a fool
    PLEASE HELP!

  30. Hi:

    help me to change de metric parameter it is set on 1 in both network adapters, and I edited allready the refered files in /etc/sysconfig/network-scripts/ifcfg-eth0 and /etc/sysconfig/network-scripts/ifcfg-eth1, and it di not worked, is there another way to doit i am using an entreprise edition,
    thanks.

Leave a Comment