jor*_*ane 7 freebsd networking netbsd ifconfig
我声明了一个ifconfig
在脚本中使用的 IPv6 地址。然后立即使用此地址侦听 TCP 端口。
当我像这样编写脚本时,它失败了,因为服务无法侦听:
ifconfig igb0 inet6 2001:db8::10/64 add
service my_service start #fails
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做时它会成功:
ifconfig igb0 inet6 2001:db8::10/64 add
sleep 1
service my_service start
Run Code Online (Sandbox Code Playgroud)
我尝试ifconfig
在运行 -add
操作后直接编写输出。似乎ifconfig
将 IP 地址报告为暂定的,这显然阻止了服务侦听它。
自然地,等待一秒钟并希望地址可用并不是处理这个问题的好方法。如何等待暂定地址可用,或ifconfig
稍后返回以便地址全部设置?
一个地址可以处于多种状态,暂定就是其中之一。等待ifconfig
地址离开暂定状态根本不符合设计。
您可以配置为使用RFC 4429中定义的乐观 DAD 。目的是即使 DAD 尚未完成,也可以为应用程序提供一个可用的地址。您可能需要重新配置内核才能使用此功能。
一旦内核被构建为提供乐观 DAD,那么您可以通过某些 sysctl 设置来启用它。来自ip-sysctl.txt:
/proc/sys/net/ipv6/* Variables:
...
conf/interface/*:
Change special settings per interface.
The functional behaviour for certain settings is different
depending on whether local forwarding is enabled or not.
...
optimistic_dad - BOOLEAN
Whether to perform Optimistic Duplicate Address Detection (RFC 4429).
0: disabled (default)
1: enabled
use_optimistic - BOOLEAN
If enabled, do not classify optimistic addresses as deprecated during
source address selection. Preferred addresses will still be chosen
before optimistic addresses, subject to other ranking in the source
address selection algorithm.
0: disabled (default)
1: enabled
Run Code Online (Sandbox Code Playgroud)
也就是说,做类似的事情
sysctl -w net.ipv6.conf.enp2s6.optimistic_dad=1
sysctl -w net.ipv6.conf.enp2s6.use_optimistic=1
Run Code Online (Sandbox Code Playgroud)
在启动时。
归档时间: |
|
查看次数: |
6459 次 |
最近记录: |