Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running Ubuntu 12.04, and to my knowledge there is only 1 networking card on my machine (Dell laptop) --- I can't imagine why there would be more than 1.

Sometimes my internet connection runs over device eth1, at other times eth2. Possibly also eth0 at times. I don't care much which device name is used, but I do care that it always be the same.

(Since I always connect wirelessly, I expected the connection to run over a wlanX device based on my experience with Ubuntu 10.04, but, like I said, the name doesn't matter as long as it's consistent).

Running ifconfig returned:

eth0      Link encap:Ethernet  HWaddr 5c:26:0a:16:e4:31  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:22 Memory:f6fe0000-f7000000 

eth2      Link encap:Ethernet  HWaddr 00:25:56:b2:16:3e  
          inet addr:192.168.1.78  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::225:56ff:feb2:163e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:9970442 errors:1 dropped:0 overruns:0 frame:2735811
          TX packets:7466676 errors:501 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1991253521 (1.9 GB)  TX bytes:594939490 (594.9 MB)
          Interrupt:17 Base address:0xc000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2634 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2634 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:287326 (287.3 KB)  TX bytes:287326 (287.3 KB)

The contents of /etc/network/interfaces were:

auto lo
iface lo inet loopback

After running ifconfig and viewing the contents of /etc/network/interfaces, I edited /etc/network/interfaces and entered # /etc/init.d/networking restart

Now, the contents of /etc/network/interfaces are:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

And running ifconfig now returns (where XXX.XXX.XXX.XXX and YYY.YYY.YYY.YYY are not the actual addresses):

eth0      Link encap:Ethernet  HWaddr 5c:26:0a:16:e4:31  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:22 Memory:f6fe0000-f7000000 

eth2      Link encap:Ethernet  HWaddr 00:25:56:b2:16:3e  
          inet addr:192.168.1.78  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::225:56ff:feb2:163e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10329105 errors:1 dropped:0 overruns:0 frame:2751349
          TX packets:7712653 errors:609 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2531013388 (2.5 GB)  TX bytes:614377694 (614.3 MB)
          Interrupt:17 Base address:0xc000 

eth0:avahi Link encap:Ethernet  HWaddr 5c:26:0a:16:e4:31  
          inet addr:XXX.XXX.XXX.XXX  Bcast:YYY.YYY.YYY.YYY  Mask:255.255.0.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          Interrupt:22 Memory:f6fe0000-f7000000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2751 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2751 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:303844 (303.8 KB)  TX bytes:303844 (303.8 KB)

So, my question is: do the changes I made to /etc/network/interfaces have the effect of forcing the internet connection always to be run over device eth0, or at least always to be aliased by device eth0? If not, then after undoing my changes to /etc/network/interfaces, what can I do so that I can always refer to the internet connection device as eth0?

[Added below in response to request.]

The contents of /etc/udev/rules.d/70-persistent-net.rules are:

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:19.0 (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="5c:26:0a:16:e4:31", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x14e4:/sys/devices/pci0000:00/0000:00:1c.1/0000:0c:00.0/ssb0:0 (b43-pci-bridge)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:56:b2:16:3e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"

# PCI device 0x14e4:/sys/devices/pci0000:00/0000:00:1c.1/0000:0c:00.0 (wl)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:56:b2:16:3e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x14e4:/sys/devices/pci0000:00/0000:00:1c.1/0000:0c:00.0 (wl)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:25:56:b2:16:3e", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
share|improve this question
    
can you post the contents of /etc/udev/rules.d/70-persistent-net.rules –  max Apr 27 '13 at 7:30
    
@max Done. Any ideas? –  synaptik Apr 27 '13 at 23:06
    
id would try removing all those lines and rebooting for some reason the same device is listed 3 times as eth1 wlan0 eth2 –  max Apr 29 '13 at 0:23
    
@max OK. As long as I backup the file, there shouldn't be any disasters, right? Worst case scenario, internet connectivity would be down until I restore from the backed up file. Right? –  synaptik Apr 29 '13 at 2:54
    
you dont even need the file at all it would be auto regenerated if you delete it –  max Apr 30 '13 at 5:14
add comment

1 Answer

Device names are auto-assigned for each different piece of hardware. See the "HWaddr" entries? Each of those is a different MAC address. The system stores and remembers each and every hardware you have, so that each of them gets a different label and can be identified as different devices.

I don't believe you can set it up so that everything can be "eth0", if you use multiple hardware. But, you can change the labels on each interface (do so CAREFULLY).

share|improve this answer
    
The problem is that I run conky to display network transfer rates. Conky requires the device name. Since it changes on my machine, sometimes conky displays transfer rates for the wrong device. –  synaptik Apr 27 '13 at 23:07
    
The device names shouldn't be changing, except maybe in a LiveUSB environment. –  Thomas W. Apr 28 '13 at 0:58
    
That's what I would have thought. However, they sometimes do change. At least, they did change before I edited /etc/network/interfaces as shown in my original question. Any idea why them might be, or have been, changing? –  synaptik Apr 28 '13 at 3:02
    
It could be a bug, or it could be an issue with LInux and the card in question, I'm not an expert in diagnosing the situation. –  Thomas W. Apr 28 '13 at 5:44
add comment

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.