Setup static IP in redhat 6

98,680

Solution 1

You can provide static IP by editing the file /etc/sysconfig/network-scripts/ifcfg-eth0 as root user in Redhat.

It should look like this:

DEVICE=eth0
BOOTPROTO=STATIC
IPADDR=192.168.0.5
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
ONBOOT=yes

After saving this file. You need to restart the network daemon using following command.

$ sudo /etc/init.d/network stop
$ sudo /etc/init.d/network start

This should provide IP address to eth0 interface also. And ifconfig command should list eth0 also.

Solution 2

After you configure the ip address run the following commands

service NetworkManager stop
chkconfig NetworkManager off

It will retain the provided ip even after booting.

Share:
98,680

Related videos on Youtube

Phu Nguyen
Author by

Phu Nguyen

Updated on June 03, 2020

Comments

  • Phu Nguyen
    Phu Nguyen about 2 years

    I installed Redhat 6 x86_64. I am using the Network connection screen to set a static IP address like below (I want two PC's in my house to see each other: one Redhat PC and one Mac)

    192.168.0.5  
    255.255.255.0  
    192.168.0.1  
    

    When I run ifconfig it displays only lo and virbr0 information. I don't know what these items are (I don't really know much about network settings).

    When I try ifconfig -a it displays eth0, lo, sit0 and virbr0. The information for eth0 is as follows:

    Link encap : Ethernet HWaddr 90:2B:34:74:05:30
    BROADCAST MULTICAST MTU:1500 Metric:1
    RX packets:192 errors:0 dropped:0 overruns:0 frame:0
    TX packets:6 errors:0 dropped:0 overruns:0 frame:0
    collisions:0 txqueuelen:1000
    RX bytes 53811 (52.5 KiB) TX bytes:468 (468.0 b)
    Interrupt:29 Base address:0xc000
    

    Could someone help me to point out if anything wrong with my setting or how to resolve this problem?

  • Phu Nguyen
    Phu Nguyen almost 10 years
    thanks for your quick answer. i did the same thing before but cannot solve. i ran ifconfig eth0 192.168.0.5 netmask 255.255.255.0. and it solved my problem. i don't know what's wrong. With this setting, when i restarted by using /etc/init.d/network stop/start, then ifconfig --> again it hide the [eth0]
  • pradeepchhetri
    pradeepchhetri almost 10 years
    Can you try booting the computer once. After that ifconfig command should show everytime eth0. You can try using sudo ifup eth0 if you don't want to reboot.
  • Phu Nguyen
    Phu Nguyen almost 10 years
    restart help solving my problem. thank you very much
  • jsbillings
    jsbillings about 9 years
    You probably want to make sure that the network service starts on boot, so you'll want to run /sbin/chkconfig network on as root.
  • ChaimKut
    ChaimKut over 7 years
    According to RHEL 6 documentation, there is no such value as BOOTPROTO=STATIC. access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Lin‌​ux/…