[Bug 285422] IPv4 source address selection is broken (with loopbacks)

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 15 Mar 2025 08:07:53 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=285422

--- Comment #2 from Lexi Winter <lexi@hemlock.eden.le-fay.org> ---
(In reply to Marek Zarychta from comment #1)

> this is how it has been since the beginning when in FreeBSD was introduced the ability to send IPv4 packets via IPv6 next-hops.

this is not specific to IPv6 nexthops, that's just the easiest way to reproduce
it.

example using IPv4 only over wg(4) interfaces:

# ifconfig lo0 inet 1.1.1.1/32 alias
# route add -inet 2.2.2.2/32 -interface wg.uk-aai-1
add net 2.2.2.2: gateway wg.uk-aai-1 fib 0
# ping 2.2.2.2
PING 2.2.2.2 (2.2.2.2): 56 data bytes
ping: sendto: No route to host
^C
# route delete 2.2.2.2
delete host 2.2.2.2 fib 0
# ifconfig wg.uk-aai-1 1.1.1.1/32 alias
# route add -inet 2.2.2.2/32 -interface wg.uk-aai-1
add net 2.2.2.2: gateway wg.uk-aai-1 fib 0
# ping 2.2.2.2                                     
PING 2.2.2.2 (2.2.2.2): 56 data bytes

# tcpdump -ni wg.uk-aai-1 ip        
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on wg.uk-aai-1, link-type NULL (BSD loopback), snapshot length 262144
bytes
08:02:36.591066 IP 1.1.1.1 > 2.2.2.2: ICMP echo request, id 53360, seq 0,
length 64

> Why do you think that address 0.0.0.0 is the wrong one?

because this is different from how other platforms (Linux, Cisco IOS, ...)
work, in a way which is not useful: it prevents common configurations from
working, for no benefit.  it would be preferable if FreeBSD would work the way
everyone else does.

> You can still use the loopback address as the source for ping

yes, but it's not reasonable to expect the user to configure IP source address
for every application running on a host.

-- 
You are receiving this mail because:
You are the assignee for the bug.