我需要有关通过 Netplan.io 管理的本地主机接口添加黑洞路由的建议。
我的配置不起作用:
network:
version: 2
ethernet:
lo:
match:
name: lo
routes:
- to: 2001:db8:1::/48
type: blackhole
metric: 254
enp1s0:
accept-ra: true
dhcp4: false
dhcp6: false
match:
macaddress: aa:bb:cc:dd:ee:ff
set-name: enp1s0
addresses:
- 1.1.1.2/24
- 2001:db8:1::2/64
routes:
- to: default
via: 1.1.1.1
- to: default
via: 2001:db8:1::1
但与此同时,如果我尝试使用物理以太网适配器定义黑洞路由,它会神奇地起作用:
network:
version: 2
ethernet:
enp1s0:
accept-ra: true
dhcp4: false
dhcp6: false
match:
macaddress: aa:bb:cc:dd:ee:ff
set-name: enp1s0
addresses:
- 1.1.1.2/24
- 2001:db8:1::2/64
routes:
- to: 2001:db8:1::/48
type: blackhole
metric: 254
- to: default
via: 1.1.1.1
- to: default
via: 2001:db8:1::1
我做错了什么或建议如何以其他方式添加黑洞路由?
答案1
你必须设置通过参数,因为 netplan 忽略没有它的规则