尝试在 Ubuntu 18.04.2 Netplan 的语法中设置到接口的多播路由不允许类似以下内容:
routes:
- to: 224.0.0.0/4
dev: eno1
此配置不起作用:
addresses:
- 192.160.0.1/24
routes:
- to: 224.0.0.0/4
via: 192.168.0.1
如何正确设置组播路由?
答案1
在 Ubuntu 20.04 上,如果您只进行设置,to:
您将收到一条警告:
Error in network definition: unicast route must include both a 'to' and 'via' IP
似乎假设该路由是单播路由。但是,via
添加组播路由时则不需要。
正确的配置是:
ens224:
addresses:
- 192.160.0.1/24
routes:
- to: 224.0.0.0/4
scope: link
这将导致添加以下路由:
224.0.0.0/4 dev ens224 proto static scope link
scope:
描述于:
http://manpages.ubuntu.com/manpages/focal/man5/netplan.5.html
更准确地说是:
http://manpages.ubuntu.com/manpages/focal/man8/ip-route.8.html
scope SCOPE_VAL
the scope of the destinations covered by the route prefix. SCOPE_VAL may be
a number or a string from the file /etc/iproute2/rt_scopes. If this
parameter is omitted, ip assumes scope global for all gatewayed unicast
routes, scope link for direct unicast and broadcast routes and scope host
for local routes.
答案2
这些文档确实不是很清楚,但我们在以下方面有一些运气:
routes:
- to: 224.0.0.0/4
via: 0.0.0.0