ubuntu NETWORKMANAGER 和 /ETC/NETWORK/INTERFACES 同时定义虚拟接口

我正在尝试添加一个虚拟接口,以下是当前配置:

$ less /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
        post-up iptables-restore < /etc/iptables.up.rules

auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet manual

$ less /etc/NetworkManager/NetworkManager.conf
plugins=ifupdown,keyfile,ofono
dns=dnsmasq

[ifupdown]
managed=false

我都试过truefalsemanaged,但eth0:0仍然没有显示ifconfig

$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1a:4b:62:f8:f4
          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:e4600000-e4620000 

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:65536  Metric:1
          RX packets:1251 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1251 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:121285 (121.2 KB)  TX bytes:121285 (121.2 KB)

wlan0     Link encap:Ethernet  HWaddr 00:1b:77:bc:16:d5
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:77ff:febc:16d5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3382 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3048 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1593844 (1.5 MB)  TX bytes:511234 (511.2 KB)

如您所见,我有一个wlan0界面,因此我希望 NM 除了我的手动网络配置之外仍在工作,而不是直接删除。





好的,如果你有一个网卡,你可以通过这种方式添加虚拟接口

auto eth0
iface eth0 inet static
   address 192.168.1.57
   netmask 255.255.255.0
   gateway 192.168.1.1
   up ip addr add 192.168.0.57/24 dev eth0 label eth0:1
   down ip addr del 192.168.0.57/24 dev eth0 label eth0:1

我使用192.168.1.0/24net range foreth0192.168.0.0/24for eht0:1。根据您的需要进行更改。

你必须编辑 /etc/NetworkManager/NetworkManager.conf

sudo nano /etc/NetworkManager/NetworkManager.conf

这将NetworkManager.conf在我们的文本编辑器中打开文件。

现在改变:

managed=false

managed=true

更改后重新加载网络服务

sudo service networking restart

或者,如果这不起作用,请尝试

sudo ifdown eth0 && sudo ifup eth0

编辑 1

tray to add only

iface eth0:0 inet dhcp

in /etc/network/interfaces

(0)

相关推荐