使用不同的网关配置额外的公共 /24 子网

使用不同的网关配置额外的公共 /24 子网

我有一台服务器,其内部适配器配置如下:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s4f0:
        dhcp4: no
        addresses: [ 199.168.96.58/29 ]
        gateway4: 199.168.96.57
        nameservers:
            addresses: [ 8.8.8.8 ]

但是,我的托管服务提供商为我提供了一个额外的 /24 子网,该子网不使用相同的网关:

CIDR: 199.19.124.0/24
Netmask: 255.255.255.0
Gateway address: 199.19.124.1
First usable address: 199.19.124.2
Last usable address: 199.19.124.254
Usable addresses:   253

我尝试了几种设置方法,但无法使第二个适配器子网正常工作。我可以将地址添加到接口,但无法从外部 ping 通它们,也无法使用额外的适配器从外部 ping 通它们。

这是我当前的网络计划:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp3s4f0:
        dhcp4: no
        addresses: [ 199.168.96.58/29 ]
        gateway4: 199.168.96.57
        nameservers:
            addresses: [ 8.8.8.8 ]
    enp3s4f1:
        dhcp4: no
        addresses: [ 199.19.124.0/24 ]
        gateway4: 199.19.124.1
        nameservers:
            addresses: [ 8.8.8.8 ]

IP 路由

root@s191768:/etc/netplan# ip r
default via 199.168.96.57 dev enp3s4f0 proto static 
199.168.96.56/29 dev enp3s4f0 proto kernel scope link src 199.168.96.58 

已添加 IP

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp3s4f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 18:a9:05:00:9e:14 brd ff:ff:ff:ff:ff:ff
    inet 199.168.96.58/29 brd 199.168.96.63 scope global enp3s4f0
       valid_lft forever preferred_lft forever
    inet6 fe80::1aa9:5ff:fe00:9e14/64 scope link 
       valid_lft forever preferred_lft forever
3: enp3s4f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 18:a9:05:00:9e:15 brd ff:ff:ff:ff:ff:ff

是否配置

enp3s4f0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 199.168.96.58  netmask 255.255.255.248  broadcast 199.168.96.63
        inet6 fe80::1aa9:5ff:fe00:9e14  prefixlen 64  scopeid 0x20<link>
        ether 18:a9:05:00:9e:14  txqueuelen 1000  (Ethernet)
        RX packets 13923  bytes 1328243 (1.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8667  bytes 1223101 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16  

enp3s4f1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 18:a9:05:00:9e:15  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 375  bytes 26690 (26.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 375  bytes 26690 (26.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

答案1

如果您的ip a输出是相关的,那么我必须提请您注意这样一个事实,即第二个适配器实际上处于 NO_CARRIER 状态,这意味着它实际上并没有向您的提供商发送或接收任何数据包。

问题可能出在您这边(典型问题:电缆坏/断、速度协商失败),也可能出在提供商这边(例如,他们只是忘记在他们的交换机上启动您的端口,或者某种防火墙禁止了该端口)。

您的物理连接方案到底是什么?如果您确实有两根来自提供商的电缆,请尝试暂时用第一根替换第二根,因为至少第一根看起来可以正常工作。

相关内容