发新话题
打印

Linux systemd networkd 缺省启用DHCP6 获得IPv6地址

Linux systemd networkd 缺省启用DHCP6 获得IPv6地址

ubuntu server 使用systemd networkd设置网络,没有明显的配置文件,缺省启用DHCP6 获得IPv6地址。

DHCP=
Enables DHCPv4 and/or DHCPv6 client support. Accepts "yes", "no", "ipv4", or "ipv6". Defaults to "no".

Note that DHCPv6 will by default be triggered by Router Advertisement, if that is enabled, regardless of this parameter. By enabling DHCPv6 support explicitly, the DHCPv6 client will be started regardless of the presence of routers on the link, or what flags the routers pass. See "IPv6AcceptRA=".

cat /run/systemd/network/10-netplan-eth0.network

[Match]
Name=eth0

[Network]
LinkLocalAddressing=ipv6
Address=192.168.1.212/24
Gateway=192.168.1.1

参考:
https://www.freedesktop.org/software/systemd/man/systemd.network.html


Turn off IPv6 on specific interfaces
While IPv6 can be disabled globally at boot by appending ipv6.disable=1 to the kernel command line, networkd supports disabling IPv6 on a per-interface basis. When a network unit’s [Network] section has either LinkLocalAddressing=ipv4 or LinkLocalAddressing=no, networkd will not try to configure IPv6 on the matching interfaces.

Note however that even when using the above option, networkd will still be expecting to receive router advertisements if IPv6 is not disabled globally. If IPv6 traffic is not being received by the interface (e.g. due to sysctl or ip6tables settings), it will remain in the configuring state and potentially cause timeouts for services waiting for the network to be fully configured. To avoid this, the IPv6AcceptRA=no option should also be set in the [Network] section.

A network unit file’s [Network] section should therefore contain the following to disable IPv6 on its matching interfaces.

[Network]
LinkLocalAddressing=no
IPv6AcceptRA=no
参考:
https://www.flatcar.org/docs/latest/setup/customization/network-config-with-networkd/

[ 本帖最后由 linda 于 2022-2-25 12:13 编辑 ]

TOP

发新话题