刚刚安装了 Ubuntu,我的一个网卡端口不工作,无法 ping 通它的 IP - eno2。
安装期间配置的 Netplan:
# This is the network config written by 'subiquity'
network:
ethernets:
eno1:
addresses:
- 11.22.33.210/24
- 1a2a:3a4a:5a6a:16::601/64
gateway4: 11.22.33.1
gateway6: 1a2a:3a4a:5a6a:16::1
nameservers:
addresses:
- 1.1.1.1
- 1.0.0.1
- 8.8.8.8
- 8.8.4.4
- 2606:4700:4700::1111
- 2606:4700:4700::1001
- 2001:4860:4860::8888
- 2001:4860:4860::8844
accept-ra: no
eno2:
addresses:
- 22.33.44.210/24
- 1a2a:3a4a:5a6a:17::602/64
gateway4: 22.33.44.1
gateway6: 1a2a:3a4a:5a6a:17::1
nameservers:
addresses:
- 1.1.1.1
- 1.0.0.1
- 8.8.8.8
- 8.8.4.4
- 2606:4700:4700::1111
- 2606:4700:4700::1001
- 2001:4860:4860::8888
- 2001:4860:4860::8844
accept-ra: no
eno3:
addresses:
- 33.44.55.210/24
- 1a2a:3a4a:5a6a:18::603/64
gateway4: 33.44.55.1
gateway6: 1a2a:3a4a:5a6a:18::1
nameservers:
addresses:
- 1.1.1.1
- 1.0.0.1
- 8.8.8.8
- 8.8.4.4
- 2606:4700:4700::1111
- 2606:4700:4700::1001
- 2001:4860:4860::8888
- 2001:4860:4860::8844
- 2606:4700:4700::1111
- 2606:4700:4700::1001
- 2001:4860:4860::8888
- 2001:4860:4860::8844
accept-ra: no
eno4:
addresses:
- 44.55.66.210/24
- 1a2a:3a4a:5a6a:19::604/64
gateway4: 44.55.66.1
gateway6: 1a2a:3a4a:5a6a:19::1
nameservers:
addresses:
- 1.1.1.1
- 1.0.0.1
- 8.8.8.8
- 8.8.4.4
- 2606:4700:4700::1111
- 2606:4700:4700::1001
- 2001:4860:4860::8888
- 2001:4860:4860::8844
accept-ra: no
version: 2
运行此
echo 101 eno1-route >>/etc/iproute2/rt_tables
echo 102 eno2-route >>/etc/iproute2/rt_tables
echo 103 eno3-route >>/etc/iproute2/rt_tables
echo 104 eno4-route >>/etc/iproute2/rt_tables
rc.本地
#!/bin/bash
# Increasing The Transmit Queue Length
/sbin/ifconfig eno1 txqueuelen 10000
/sbin/ifconfig eno2 txqueuelen 10000
/sbin/ifconfig eno3 txqueuelen 10000
/sbin/ifconfig eno4 txqueuelen 10000
/sbin/ifconfig lo txqueuelen 10000
#routes
ip route add default via 11.22.33.1 dev eno1 table eno1-route
ip rule add from 11.22.33.210 lookup eno1-route
ip route add default via 22.33.44.1 dev eno2 table eno2-route
ip rule add from 22.33.44.210 lookup eno2-route
ip route add default via 33.44.55.1 dev eno3 table eno3-route
ip rule add from 33.44.55.210 lookup eno3-route
ip route add default via 44.55.66.1 dev eno4 table eno4-route
ip rule add from 44.55.66.77 lookup eno4-route
应用 netplan 时出现此错误。
** (generate:5742): WARNING **: 05:13:22.079: Problem encountered while validating default route consistency.Please set up multiple routing tables and use `routing-policy` instead.
Error: Conflicting default route declarations for IPv4 (table: main, metric: default), first declared in eno2 but also in eno4
重启后,所有 IP(包括 IPv4 和 IPv6)似乎都可以 ping 通。发生了什么?我已经有不同的路由表。默认路由声明有冲突!?
ip route list
返回
default via 22.33.44.1 dev eno2 proto static
default via 33.44.55.1 dev eno3 proto static
default via 11.22.33.1 dev eno1 proto static
default via 44.55.66.1 dev eno4 proto static
44.55.66.0/24 dev eno4 proto kernel scope link src 44.55.66.210
11.22.33.0/24 dev eno1 proto kernel scope link src 11.22.33.210
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
22.33.44.0/24 dev eno2 proto kernel scope link src 22.33.44.210
33.44.55.0/24 dev eno3 proto kernel scope link src 33.44.55.210
答案1
你有不同的路由表,但当您使用gateway4
和gateway6
简写时,这不会使用这些路由表。要获得所需的结果,您需要将默认路由拼写为,而routes:
不是如中所述https://netplan.io/reference/#default-routes。
答案2
“应用 netplan 时出现此错误。
** (generate:5742):警告 **:05:13:22.079:验证默认路由一致性时遇到问题。请设置多个路由表并改用routing-policy
。错误:IPv4 的默认路由声明冲突(表:main,度量:default),首先在 eno2 中声明,但也在 eno4 中声明”
检查 /etc/netplan 文件夹中是否存在多个 YAML 配置文件。
如果超过一个文件,则清除单个文件可能会解决冲突。
我收到了此错误消息,并发现 99-netplan 文件与标准 00-installer-config.yaml 文件冲突。
删除 99 文件即可解决该问题。