设置多个网络接口 /etc/network/interfaces

设置多个网络接口 /etc/network/interfaces

我正在尝试设置我的 4 个网络接口,使其具有特定的 dns-nameservers 和 dns-search,以便我可以使用其中任何一个连接到我的域,但它无法正常工作,因为当我运行时systemctl restart networking.service它一直在加载但从不工作。它只有在我设置一个时才会起作用,所以我做错了什么,但不确定到底是什么,如果有人可以建议的话。

这是我的 /etc/network/interfaces,它不起作用:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto enp6s0
iface enp6s0 inet dhcp
    dns-nameservers 120.139.14.230 120.139.14.231
    dns-search ad.mydomain.com
auto enp7s0
iface enp7s0 inet dhcp
    dns-nameservers 120.139.14.230 120.139.14.231
    dns-search ad.mydomain.com
auto ens7f0
iface ens7f0 inet dhcp
    dns-nameservers 120.139.14.230 120.139.14.231
    dns-search ad.mydomain.com
auto ens7f1
iface ens7f1 inet dhcp
    dns-nameservers 120.139.14.230 120.139.14.231
    dns-search ad.mydomain.com

它的工作原理如下:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
#auto enp6s0
#iface enp6s0 inet dhcp
#    dns-nameservers 120.139.14.230 120.139.14.231
#    dns-search ad.mydomain.com
#auto enp7s0
#iface enp7s0 inet dhcp
#    dns-nameservers 120.139.14.230 120.139.14.231
#    dns-search ad.mydomain.com
auto ens7f0
iface ens7f0 inet dhcp
    dns-nameservers 120.139.14.230 120.139.14.231
    dns-search ad.mydomain.com
#auto ens7f1
#iface ens7f1 inet dhcp
#    dns-nameservers 120.139.14.230 120.139.14.231
#    dns-search ad.mydomain.com

所以我想知道如何设置所有接口以具有相同的 dns-nameservers 和 dns-search?

ifconfig -a 的输出:

enp6s0    Link encap:Ethernet  HWaddr 2c:4d:54:44:a0:25  
          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)
          Memory:ce400000-ce47ffff 

enp7s0    Link encap:Ethernet  HWaddr 2c:4d:54:44:a0:26  
          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)
          Memory:ce300000-ce37ffff 

ens7f0    Link encap:Ethernet  HWaddr a0:36:9f:f5:c2:b8  
          inet addr:120.139.195.90  Bcast:120.139.195.255  Mask:255.255.254.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29651 errors:0 dropped:1 overruns:0 frame:0
          TX packets:7066 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:8988328 (8.9 MB)  TX bytes:1500983 (1.5 MB)

ens7f1    Link encap:Ethernet  HWaddr a0:36:9f:f5:c2:b9  
          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)

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:44822 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44822 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3514738 (3.5 MB)  TX bytes:3514738 (3.5 MB)

ip link show 输出:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp6s0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether 2c:4d:54:44:a0:25 brd ff:ff:ff:ff:ff:ff
3: enp7s0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether 2c:4d:54:44:a0:26 brd ff:ff:ff:ff:ff:ff
4: ens7f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether a0:36:9f:f5:c2:b8 brd ff:ff:ff:ff:ff:ff
5: ens7f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000
    link/ether a0:36:9f:f5:c2:b9 brd ff:ff:ff:ff:ff:ff

相关内容