希望有人能帮助我,我想要做的是更改 Ubuntu 12.04LTS 上的接口顺序。我们在具有三个虚拟接口的 VMWare 机器上运行 Ubuntu 服务器。
我已经阅读了如何控制网络接口的up顺序?但它似乎没有提供我们所寻找的东西。
我们遇到了一个小问题,我们正在运行的一款软件使用它找到的第一个接口作为控制接口。我们实际上需要它使用第三个接口。我们已经与供应商核实过,他们确认我们无法配置软件来指定哪个接口。不过,这是另一回事了。
当前 ifconfig 看起来像这样:
eth0 Link encap:Ethernet HWaddr 00:0c:29:b5:dd:c1
inet addr:192.168.10.117 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb5:ddc1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:1368 (1.3 KB)
eth1 Link encap:Ethernet HWaddr 00:0c:29:b5:dd:cb
inet addr:192.168.20.117 Bcast:192.168.20.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb5:ddcb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:660 (660.0 B) TX bytes:468 (468.0 B)
eth2 Link encap:Ethernet HWaddr 00:0c:29:b5:dd:d5
inet addr:192.168.30.117 Bcast:192.168.30.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb5:ddd5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:9 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:540 (540.0 B) TX bytes:468 (468.0 B)
我们理想情况下希望现在的 eth2 和 MAC 为00:0c:29:b5:dd:d5
eth0。当我们进行/etc/network/interfaces
相应更改时,我们得到了更改,但不正确:
eth0 Link encap:Ethernet HWaddr 00:0c:29:b5:dd:c1
inet addr:192.168.30.117 Bcast:192.168.30.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb5:ddc1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:526 (526.0 B) TX bytes:1666 (1.6 KB)
eth1 Link encap:Ethernet HWaddr 00:0c:29:b5:dd:cb
inet addr:192.168.20.117 Bcast:192.168.20.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb5:ddcb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17 errors:0 dropped:0 overruns:0 frame:0
TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1246 (1.2 KB) TX bytes:706 (706.0 B)
eth2 Link encap:Ethernet HWaddr 00:0c:29:b5:dd:d5
inet addr:192.168.10.117 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb5:ddd5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:13 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:946 (946.0 B) TX bytes:946 (946.0 B)
有人能想到改变接口顺序的方法吗?
我们相信这可以通过 VMWare 来完成,但在理想情况下,如果无需重新启动服务器就可以完成,那就太好了。
我可能问错了问题,或者问的方式不对。任何指点都将不胜感激!
答案1
正如评论中所建议的,我显然没有进行足够的搜索......:)
在我上面的例子中:
nano /etc/udev/rules.d/70-persistent-net.rules
输入以下内容,并在正确的位置输入正确的 MAC 地址:
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:b5:dd:d5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:b5:dd:cb", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:b5:dd:c1", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
重新启动服务器,您将看到类似以下内容:
eth0 Link encap:Ethernet HWaddr 00:0c:29:b5:dd:d5
inet addr:192.168.30.117 Bcast:192.168.30.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb5:ddd5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1260 (1.2 KB) TX bytes:468 (468.0 B)
eth1 Link encap:Ethernet HWaddr 00:0c:29:b5:dd:cb
inet addr:192.168.20.117 Bcast:192.168.20.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb5:ddcb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1260 (1.2 KB) TX bytes:468 (468.0 B)
eth2 Link encap:Ethernet HWaddr 00:0c:29:b5:dd:c1
inet addr:192.168.10.117 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feb5:ddc1/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:1728 (1.7 KB)