Open jackyzy823 opened 2 years ago
That's a creative solution, but I have a better suggestion, borrowed from HAProxy's transparent
option:
Foreign sockets
IPV6_TRANSPARENT (Linux) / IP_FREEBIND (Linux,FreeBSD?) / IPV6_BINDANY (NetBSD,FreeBSD?) / SO_BINDANY (OpenBSD)
This would be set as a configuration option, per-interface, and then the kernel should just accept the values set, and permit it on a per-interface basis, which is safer than the sysctl, and more portable.
current AdvRASrcAddress will only be used when matched one of valid link local addresses.
https://github.com/radvd-project/radvd/blob/b368cb98da5da44154994de573fea24b7c7858fc/device-common.c#L182
I hope that when sysctl
net.ipv6.ip_nonlocal_bind=1
is set, AdvRASrcAddress can directly set iface->props.if_addr_rasrc whatever it is a valid link local addresses or not .Reason: It maybe a rare case . My VPS provider offers an IPv6 Prefix to a machine. I want to set SLAAC in that machine.
when i use normal radvd.conf ,I can get an IPv6 address , but i must set a gateway manually to
fe80::1
to make the connection work. (maybe related to https://serverfault.com/a/1069528).Because the RA message is sent in the just same machine to itself , so it takes self link local address as gateway.
Then I found
AdvRASrcAddress
option , but when i setAdvRASrcAddress { fe80::1 ; };
, radvd refuse to work sayinginterface eth0 does not exist or is not set up properly, ignoring the interface
because ofno configured AdvRASrcAddress present, skipping send
.Finally, I tried short circuit the code and set
sysctl net.ipv6.ip_nonlocal_bind=1
And it works. I can do SLAAC and the gateway is
fe80::1
and connection works.