I have a machine that has eth0 and eth1, and now I want to create an eth2 and assign it some IP address.

What's the command for doing this?

link|improve this question

56% accept rate
feedback

2 Answers

On Linux machines, eth0 and eth1 correspond to real network ports. To add an eth2, you'll need to add another NIC, either by adding an internal PCI(e) network card, or by adding a USB network adapter. See Redhat network interface configuration.

If all you want is another IP address, you can create an ethernet alias on one of your existing adapters. An alias is like a virtual network card -- it lets you assign another IP address to an existing port. Let's assume your eth0 has the IP address 192.168.1.5.

To do this once, run (as root) ifconfig eth0:0 192.168.1.6 up. (Use eth0:1 for a second alias on eth0, eth0:2 for a third, or eth1:0 to alias eth1 instead of eth0.) This configuration will be lost at reboot.

To configure it permanently, add it to a configuration script. Make a copy of /etc/sysconfig/network-scripts/ifcfg-eth0 to the file ifcfg-eth0:0 in the same directory. Change the new file so it looks like this:

DEVICE=eth0:0
IPADDR=192.168.1.6
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
NAME=eth0:0

The remove or comment out any GATEWAY lines in both files, and add the GATEWAY line to your /etc/sysconfig/network file. Then you can start the new alias with ifup eth0:0 or restart networking entirely with service network restart.

link|improve this answer
feedback
  • Shutdown comuputer
  • Disconnect from power
  • Open Case
  • Insert NIC
  • Close case
  • Reconnect power
  • Boot Computer
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.