Ubuntu Server 18.04 同一子网上的两个网卡

Ubuntu Server 18.04 同一子网上的两个网卡

我有安装了 2 个 NIC 卡的 Ubuntu Server 18.04,并且它们都通过分配了静态 IP netplan

这是我的配置:

root@box2:/etc/netplan# cat 01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      addresses: [192.168.0.11/24]
      nameservers:
        addresses: [62.179.1.60,8.8.8.8]
      dhcp4: no
      routes:
      - from: 192.168.0.11        
        on-link: true
        to: 0.0.0.0/0
        via: 192.168.0.1
        metric: 100
    eno2:
      addresses: [192.168.0.12/24]
      # gateway4: 192.168.0.1
      nameservers:
        addresses: [62.179.1.60,8.8.8.8]
      dhcp4: no
      routes:
      - from: 192.168.0.12
        on-link: true
        to:  0.0.0.0/0
        via: 192.168.0.1
        metric: 1000

root@box2:/etc/netplan# ip r
default via 192.168.0.1 dev eno1 proto static src 192.168.0.11 metric 100 onlink 
default via 192.168.0.1 dev eno2 proto static src 192.168.0.12 metric 1000 onlink 
192.168.0.0/24 dev eno2 proto kernel scope link src 192.168.0.12 
192.168.0.0/24 dev eno1 proto kernel scope link src 192.168.0.11 

root@box2:/etc/netplan# sysctl -a | grep net.ipv4.conf.*.arp
net.ipv4.conf.all.arp_accept = 0
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.all.arp_filter = 1
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_notify = 0
net.ipv4.conf.all.drop_gratuitous_arp = 0
net.ipv4.conf.all.proxy_arp = 0
net.ipv4.conf.all.proxy_arp_pvlan = 0
net.ipv4.conf.default.arp_accept = 0
net.ipv4.conf.default.arp_announce = 0
net.ipv4.conf.default.arp_filter = 0
net.ipv4.conf.default.arp_ignore = 0
net.ipv4.conf.default.arp_notify = 0
net.ipv4.conf.default.drop_gratuitous_arp = 0
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.default.proxy_arp_pvlan = 0
net.ipv4.conf.eno1.arp_accept = 0
net.ipv4.conf.eno1.arp_announce = 0
net.ipv4.conf.eno1.arp_filter = 0
net.ipv4.conf.eno1.arp_ignore = 0
net.ipv4.conf.eno1.arp_notify = 0
net.ipv4.conf.eno1.drop_gratuitous_arp = 0
net.ipv4.conf.eno1.proxy_arp = 0
net.ipv4.conf.eno1.proxy_arp_pvlan = 0
net.ipv4.conf.eno2.arp_accept = 0
net.ipv4.conf.eno2.arp_announce = 0
net.ipv4.conf.eno2.arp_filter = 0
net.ipv4.conf.eno2.arp_ignore = 0
net.ipv4.conf.eno2.arp_notify = 0
net.ipv4.conf.eno2.drop_gratuitous_arp = 0
net.ipv4.conf.eno2.proxy_arp = 0
net.ipv4.conf.eno2.proxy_arp_pvlan = 0
net.ipv4.conf.lo.arp_accept = 0
net.ipv4.conf.lo.arp_announce = 0
net.ipv4.conf.lo.arp_filter = 0
net.ipv4.conf.lo.arp_ignore = 0
net.ipv4.conf.lo.arp_notify = 0
net.ipv4.conf.lo.drop_gratuitous_arp = 0
net.ipv4.conf.lo.proxy_arp = 0
net.ipv4.conf.lo.proxy_arp_pvlan = 0

ping两个 IP 在内部网络上均可正常工作。

不起作用的是从eno1接口 ping 到外部。我怀疑这与路由有关。

我的主要目标是让eno1接口成为所有流量的主要接口,并eno2作为附加接口 - 两者都具有互联网访问权限。

相关内容