How to add an IP address to the network interface?

Issues related to configuring your network
Post Reply
sethdavis
Posts: 3
Joined: 2008/07/23 18:05:11
Contact:

How to add an IP address to the network interface?

Post by sethdavis » 2011/08/30 00:39:06

How does one add an IP address (or multiple IP addresses) to his/her network interface in CentOS 6? It used to be that you edited "eth0:X" files in /etc/sysconfig/network-scripts, but now /etc/sysconfig/network-scripts just shows ifcfg-lo and ifcfg-Private.

Thanks,
Seth

scottro
Forum Moderator
Posts: 2556
Joined: 2007/09/03 21:18:09
Location: NYC
Contact:

How to add an IP address to the network interface?

Post by scottro » 2011/08/30 00:56:52

That doesn't sound right. There should also be an ifcfg-eth0 in there.

Does CentOS seem to recognize your interface? If so, I would try doing something like dhclient eth0, assuming there's a DHCP server available, then installing system-config-network-tui.

Using that, you can configure the interface, and it should create that ifcfg-eth0 file. You might want to edit the file after that though, as it seems, nowadays, to have it ONBOOT=no. (And possibly NM_CONTROLLED=yes, but that might be Fedora only)

If you don't have a dhcp server handy, but an eth0 interface is seen by the system, you can manually configure it once to install system-config-network-tui. (Or put in the CD, mount it, and use the media.repo.

You probably know the old syntax, but in case not, assuming your network was 192.168.1.x and gateway 192.168.1.1


ifconfig 192.168.1.50 netmask 255.255.255.0


route add net 192.168.1.0 netmask 255.255.255.0 eth0

route add default gw 192.168.1.1 eth0

Then stick a name server in /etc/resolv.conf, 8.8.8.8 is a public one that can be used, or opendns.


nameserver 208.67.222.222

And you should be good to go.

All this is assuming that the system _does_ see your ethernet card.

Post Reply