互联网连接设备不一致(eth0 eth1 eth2)

互联网连接设备不一致(eth0 eth1 eth2)

我正在运行 Ubuntu 12.04,据我所知,我的机器(戴尔笔记本电脑)上只有 1 个网卡 --- 我无法想象为什么会有超过 1 个。

有时我的互联网连接通过设备 运行eth1,有时通过 运行eth2eth0有时也可能如此。我不太在意使用哪个设备名称,但我确保它始终是一样的。

(由于我总是通过无线连接,根据我使用 Ubuntu 10.04 的经验,我预计连接将通过wlanX设备运行,但是,就像我说的,只要名称一致,名称并不重要)。

正在运行ifconfig返回:

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)

内容/etc/network/interfaces如下:

auto lo
iface lo inet loopback

运行ifconfig并查看内容后/etc/network/interfaces,我编辑/etc/network/interfaces并输入# /etc/init.d/networking restart

现在,的内容/etc/network/interfaces是:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

现在运行ifconfig将返回(其中XXX.XXX.XXX.XXXYYY.YYY.YYY.YYY不是实际地址):

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)

所以,我的问题是:我所做的更改是否/etc/network/interfaces会强制互联网连接始终通过设备 运行eth0,或至少始终以设备为别名eth0?如果不是,那么在撤消对 的更改后/etc/network/interfaces,我该怎么做才能始终将互联网连接设备称为eth0

[根据请求添加如下。]

其内容/etc/udev/rules.d/70-persistent-net.rules为:

# 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"

答案1

设备名称会为每个不同的硬件自动分配。看到“HWaddr”条目了吗?每个条目都是不同的 MAC 地址。系统会存储并记住您拥有的每个硬件,以便每个硬件都有不同的标签,并且可以被识别为不同的设备。

如果您使用多个硬件,我认为您无法将其设置为让所有设备都为“eth0”。但是,您可以更改每个接口上的标签(请小心操作)。

相关内容