Sunday, May 24, 2009

Setting ip in redhat,fedora and centos

For redhat, fedora and centos, to set ip temporarily, you can use ifconfig and route commands(you have to be root to do these steps)

1. Run the command below to set ip and netmask
# ifconfig eth0 netmask up
where eth0 is the name of the interface, is the netmask and up to activate the interface

2. run route command to set default gateway
# route add default gw
where is your gateway ip

3. You can check the configuration that you have setup using commands route -n to see the gateway and ifconfig to see the ip address

To setup the ip and gateway permanently, follow below steps (You have to be root to do these steps)

1. Go to folder /etc/sysconfig/network-scripts
# cd /etc/sysconfig/network-scripts

2. Backup your existing configuration
# cp ifcfg-eth0 ifcfg-eth0.bak

3. Open ifcfg-eth0 with your favorite editor
# vi ifcfg-eth0

4. Add below line to the ifcfg-eth0 file to setup your ip


5. Save the file

6. Add below line to /etc/sysconfig/network to set your gateway

7. Save and restart network
# /etc/init.d/network restart

8. Done. Check your newly created ip using ifconfig and gateway using route -n commands

No comments: