首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Systemd网络: IPv6网络在引导时不可用

Systemd网络: IPv6网络在引导时不可用
EN

Unix & Linux用户
提问于 2015-11-26 10:33:20
回答 1查看 2.9K关注 0票数 3

我有一台Debian机器运行多个静态IPv4和IPv6地址,由systemd自己在/etc/systemd/network/10-static-eth0.network中管理,如下所示:

代码语言:javascript
复制
[Match]
Name=eth0

[Network]
Address=2a04:----::149/64
Address=2a04:----::242/64
Address=2a04:----::243/64
Gateway=2a04:----:0001

Address=5.----.149/25
Address=5.----.242/25
Address=5.----.243/25
Gateway=5.----.129

DNS=89.----.4
DNS=46.----.104

我有多个进程,通过systemd单元(如OpenVPN、Bind9等)从系统开始,它们都被设置为绑定到接口eth0的特定IP。但是,它们无法启动,因为它们在启动后无法绑定到IPv6地址。

我怎么知道的?

我制作了两个测试单元,它们使用pingping6在目标network.targetnetwork-online.target之后测试网络,这种情况发生了:

IPv4测试结果:

代码语言:javascript
复制
server.example:~# systemctl status abootping.service
● abootping.service - A boot-time ping for network testing
   Loaded: loaded (/lib/systemd/system/abootping.service; enabled)
   Active: inactive (dead) since Thu 2015-11-26 11:01:58 CET; 45s ago
 Main PID: 433 (code=exited, status=0/SUCCESS)

Nov 26 11:01:54 server.example ping[433]: PING test-ping-host.example (89.-----.8) from 5.----.149 : 56(84) bytes of data.
Nov 26 11:01:54 server.example ping[433]: 64 bytes from test-ping-host.example (89.-----.8): icmp_seq=1 ttl=59 time=4.92 ms
Nov 26 11:01:55 server.example ping[433]: 64 bytes from test-ping-host.example (89.-----.8): icmp_seq=2 ttl=59 time=4.92 ms
Nov 26 11:01:56 server.example ping[433]: 64 bytes from test-ping-host.example (89.-----.8): icmp_seq=3 ttl=59 time=4.84 ms
Nov 26 11:01:57 server.example ping[433]: 64 bytes from test-ping-host.example (89.-----.8): icmp_seq=4 ttl=59 time=5.41 ms
Nov 26 11:01:58 server.example ping[433]: 64 bytes from test-ping-host.example (89.-----.8): icmp_seq=5 ttl=59 time=4.95 ms
Nov 26 11:01:58 server.example ping[433]: --- test-ping-host.example ping statistics ---
Nov 26 11:01:58 server.example ping[433]: 5 packets transmitted, 5 received, 0% packet loss, time 4007ms
Nov 26 11:01:58 server.example ping[433]: rtt min/avg/max/mdev = 4.843/5.010/5.414/0.209 ms

IPv6测试结果:

代码语言:javascript
复制
server.example:~# systemctl status abootping6.service
● abootping6.service - A boot-time ping6 for network testing
   Loaded: loaded (/lib/systemd/system/abootping6.service; enabled)
   Active: failed (Result: exit-code) since Thu 2015-11-26 11:01:54 CET; 56s ago
 Main PID: 436 (code=exited, status=2)

Nov 26 11:01:54 server.example ping6[436]: ping: bind icmp socket: Cannot assign requested address
Nov 26 11:01:54 server.example systemd[1]: abootping6.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Nov 26 11:01:54 server.example systemd[1]: Failed to start A boot-time ping6 for network testing.
Nov 26 11:01:54 server.example systemd[1]: Unit abootping6.service entered failed state.

正如您所看到的,IPv4在引导后运行得很好,但是IPv6没有工作,所有需要IPv6的引导进程都会失败绑定。

关于我的network-online.target

为了确保我的引导单元只在网络真正工作之后才启动,我将After=network.target network-online.target添加到所有这些单元中。

network-online.target本身就有这样的wants

这包括:

代码语言:javascript
复制
[Unit]
Description=Wait for Network to be Configured
Documentation=man:systemd-networkd-wait-online.service(8)
DefaultDependencies=no
Conflicts=shutdown.target
Requisite=systemd-networkd.service
After=systemd-networkd.service
Before=network-online.target

[Service]
Type=oneshot
ExecStart=/lib/systemd/systemd-networkd-wait-online
RemainAfterExit=yes

[Install]
WantedBy=network-online.target

根据文档的说法:

系统-网络-等待-在线是一个单一的系统服务,等待网络被配置。默认情况下,它将等待它知道并由systemd-networkd.service(8)管理的所有链路完全配置或失败,并等待至少一个链路获得载波。

这个服务等待的真正效果在引导时是显而易见的,我的测试ping服务尊重它:

SSH登录后的

ping

在每个人都认为我的IPv6网络没有正确配置之前,这里有一些其他的证明:

  1. 如果我在启动后立即将SSH放到机器上,然后尝试使用ping6,它就能工作: server.example:~# ping6 -I 2A04:64字节来自test- ping -host.示例: icmp_seq=3 ttl=59 time=7.31 ms ^C3接收,包丢失0%,时间2003 ms rtt min/avg/max/mdev = 7.314/7.381/7.415/0.047 ms
  2. 例如,如果我重新启动lighttpd,它将正确地绑定到它应该绑定的IPv6,并且我可以使用另一台计算机上的IPv6客户端或ping6打开托管网站。

这是我的问题:这正常吗?IPv6是否也能工作,因为systemd-networkd-wait-online确保它是可用的?或者..。at least one link to gain a carrier.是否真的意味着,在我得到一个工作的IPv4之后,它将停止等待,并且IPv6地址仍然不可路由?我怎么才能解决这个问题?

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2019-07-04 17:27:47

显然我是对的,它不是在等IPv6。我把这个问题贴在了项目的Github上,有人把它标记为RFE:https://github.com/systemd/systemd/issues/2037

检查此选项以获得暂时修复问题的解决方案(禁用IPv6 DAD):http://serverfault.com/questions/766253/ensure-systemd-wait-for-ipv6-before-start-service-unit

票数 1
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/245635

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档