Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How would I go about installing eth0 on CentOS? When I do ifconfig -a, eth0 is not there. Here is the output of ip link:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
3: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue
    link/void
share|improve this question
1  
What do you mean by installng eth0? Is CentOS not seeing your network card? What is the output of the ip link command? Also, what CentOS version are you using? –  Cristian Ciupitu Jun 23 at 19:43
    
What card is it? –  schaiba Jun 23 at 19:49
    
What do you mean by what card? –  user68973 Jun 23 at 19:54
    
@user68973, are you using a virtual private server (VPS)? –  Cristian Ciupitu Jun 23 at 19:55
    
Yes, I am. It's Linux. –  user68973 Jun 23 at 19:59

2 Answers 2

Network interfaces can have different names on Linux depending on their type (wired Ethernet, Wi-Fi, PPP, SLIP, etc.), PCI slot, initialization order, etc. For example if a computer has a single Ethernet card, its name would be eth0*.

In your case, there's a virtual private server without an Ethernet network card in it, not even an emulated one. Nevertheless you have a network card named venet0. You can rename it with:

ip link set venet0 name eth0

If the interface is in use the command will fail, so you might need to bring it down (ip link set venet0 down), but this will probably disconnect you from the server.

If you're willing to take the risk, you could run in the background a script that brings the interface down, renames it, then brings it up. First get the settings for venet0 and the routing table:

[root@server ~]# ip addr show dev venet0
2: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
    link/void
    inet 127.0.0.1/32 scope host venet0
    inet X.Y.Z.T/32 brd X.Y.Z.T scope global venet0:0
[root@server ~]# ip ro
192.0.2.0/24 dev venet0  scope host
169.254.0.0/16 dev venet0  scope link  metric 1002
default dev venet0  scope link

Then create a script (rename-to-eth0.sh) similar to this:

#!/bin/sh
### Rename
ip link set venet0 down        # Bring interface down
ip link set venet0 name eth0   # Rename interface    
ip link set eth0 up            # Bring interface up
### Restore
# Restore interface settings. Adapt accordingly!!!
ip addr add 127.0.0.1/32 scope host dev eth0
ip addr add X.Y.Z.T/32 brd X.Y.Z.T scope global label eth0:0 dev eth0
# Restore routing table. Adapt accordingly!!!
ip ro add 192.0.2.0/24 dev venet0 scope host
ip ro add 169.254.0.0/16 dev venet0 scope link metric 1002
ip ro add default dev eth0

Now run the script with nohup i.e. nohup ./rename-to-eth0.sh or inside screen, tmux, etc. If it fails, you'll probably have to restart the server.

* Things will change as the "Predictable Network Interface Names" proposal is implemented, although this does not apply to CentOS6 or earlier. Take note that according to this proposal an integrated Ethernet card might be named em1.

share|improve this answer
    
I tried that it didn't work for the script I have, I need eth0. –  user68973 Jun 23 at 20:29
    
@user68973, I've updated my answer with an (ugly) way to do the rename. –  Cristian Ciupitu Jun 24 at 0:19
    
+1 for explaining why there isn't an eth0. Any script that has eth0 hardcoded into it sounds like a really badly done piece of work, BTW. –  goldilocks Jun 24 at 11:43
    
Thank you! I agree regarding the script. And if it's really a script then it should be easier to adapt it (with a plain search&replace perhaps) than mess with this renaming. –  Cristian Ciupitu Jun 24 at 16:18

If your use of eth0 can simply be modified to refer to the network interface by the name "venet0" wherever you would use "eth0" then you can just do that.

If, however, you have to have the name eth0, you can do something like

sudo ip link set dev venet0 alias eth0

The "sudo" prefix allows you to execute commands as "root" user. If you're already running as root, you can leave this off. In fact, probably you should try it without and if there are no errors then you win!

share|improve this answer
    
I'd recommend using su -l -c instead of sudo because not every computer has sudo. –  Cristian Ciupitu Jun 23 at 20:13
    
here is the output of that command Error: either "dev" is duplicate, or "alias" is a garbage. –  user68973 Jun 23 at 20:19

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.