配置网络接口

配置网络接口

我在运行 Ubuntu 12.04 的 VMware 上启动 eth1 和 eth0 时遇到了问题,我有 2 个网桥和 1 个 NAT,这是我的 ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0c:29:7f:05:19  
          inet addr:10.10.10.51  Bcast:10.10.10.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe7f:519/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:583 errors:0 dropped:0 overruns:0 frame:0
          TX packets:117 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:76518 (76.5 KB)  TX bytes:18000 (18.0 KB)
          Interrupt:19 Base address:0x2024 

eth1      Link encap:Ethernet  HWaddr 00:0c:29:7f:05:23  
          inet addr:192.168.2.60  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe7f:523/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:631 errors:0 dropped:0 overruns:0 frame:0
          TX packets:59 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:85875 (85.8 KB)  TX bytes:8921 (8.9 KB)
          Interrupt:19 Base address:0x20a4 

eth2      Link encap:Ethernet  HWaddr 00:0c:29:7f:05:2d  
          inet addr:192.168.112.205  Bcast:192.168.112.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe7f:52d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:147 errors:0 dropped:0 overruns:0 frame:0
          TX packets:283 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:42615 (42.6 KB)  TX bytes:42952 (42.9 KB)
          Interrupt:16 Base address:0x2424 

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:103 errors:0 dropped:0 overruns:0 frame:0
          TX packets:103 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:8632 (8.6 KB)  TX bytes:8632 (8.6 KB)

这是我的界面

auto lo
iface lo inet loopback

auto eth2
iface eth2 inet dhcp

auto eth0
iface eth0 inet static
address 10.10.10.51
netmask 255.255.255.0
gateway 10.10.10.1

auto eth1
iface eth1 inet static
address 192.168.2.60
netmask 255.255.255.0
gateway 192.168.2.1

这是我在运行 /etc/init.d/networking restart 时遇到的错误

root@ubuntu:/home/advitor# /etc/init.d/networking restart
 * Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
 * Reconfiguring network interfaces...                                           * Disconnecting iSCSI targets
   ...done.
 * Stopping iSCSI initiator service
   ...done.
 * Starting iSCSI initiator service iscsid
   ...done.
 * Setting up iSCSI targets
   ...done.
ssh stop/waiting
ssh start/running, process 4394
RTNETLINK answers: File exists
Failed to bring up eth0.
RTNETLINK answers: File exists
Failed to bring up eth1.

我尝试运行 ifup -v 来显示有关 eth0 和 eth1 的更多信息,它给出了这个。

root@ubuntu:/home/advitor# ifup -v eth1
Configuring interface eth1=eth1 (inet)
run-parts --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/ethtool
run-parts: executing /etc/network/if-pre-up.d/vlan
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
ip addr add 192.168.2.60/255.255.255.0 broadcast +    dev eth1 label eth1
RTNETLINK answers: File exists
Failed to bring up eth1.

root@ubuntu:/home/advitor# ifup -v eth0
Configuring interface eth0=eth0 (inet)
run-parts --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/ethtool
run-parts: executing /etc/network/if-pre-up.d/vlan
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant
ip addr add 10.10.10.51/255.255.255.0 broadcast +     dev eth0 label eth0
RTNETLINK answers: File exists
Failed to bring up eth0.

我希望您能指导我如何解决这个问题。

答案1

显然,不再建议使用 /etc/init.d/networking restart(如您的输出所示)。如解释的那样这里,首选方法是手动关闭和打开接口。

您可以尝试一下并看看是否有帮助吗?

ifdown eth0
ifup eth0
ifdown eth1
ifup eth1

相关内容