Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Based on your description I believe this answer will suite your demands better: http://stackoverflow.com/questions/2082722/how-do-i-create-virtual-ethernet-dev‌​ices-in-linux –  mnmnc Jul 22 at 23:21

2 Answers 2

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.

share|improve this answer
    
adding NM_CONTROLLED="no" can help too (rhel6) –  sje397 Nov 30 '12 at 6:30

Follow these steps:

  1. Shutdown the computer
  2. Disconnect from power
  3. Open case
  4. Insert NIC
  5. Close case
  6. Reconnect power
  7. Boot computer
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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