Date: Sat, 11 Nov 2023 19:03:40 +0800 From: Zhenlei Huang <zlei@FreeBSD.org> To: Benoit Chesneau <benoitc@enki-multimedia.eu> Cc: "freebsd-net@FreeBSD.org" <freebsd-net@freebsd.org> Subject: Re: loopback and IP source Message-ID: <7BA2954F-D9DF-4D95-A8A8-9FF8E1A07E63@FreeBSD.org> In-Reply-To: <t6vS0O-obl2X2h0RWRfvlnxquCn7nlg1zJfFPPL7hfb_HjUxvnaOx2CbRXSOYJWDatxOea3CieEnUEUbL5XnIOh7hP2f6JqwqpZUDBwdsVE=@enki-multimedia.eu> References: <t6vS0O-obl2X2h0RWRfvlnxquCn7nlg1zJfFPPL7hfb_HjUxvnaOx2CbRXSOYJWDatxOea3CieEnUEUbL5XnIOh7hP2f6JqwqpZUDBwdsVE=@enki-multimedia.eu>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] > On Nov 11, 2023, at 5:56 PM, Benoit Chesneau <benoitc@enki-multimedia.eu> wrote: > > Is there a way to ensure that the IP set in loopback on the rc.conf is always used as source for routing. I setup it like this: > > ``` > cloned_interfaces="lo1" > ifconfig_lo1="inet 195.24.245.226/32 up" > ifconfig_lo1_ipv6="inet6 2a12:5541:1:1::3/128" > ``` > > and others IP are set on interfaces or vlans. All routes informations are fetched via BGP. The strange thing is that when I do a ping to `1.1.1.1`` this work (and pass via one of the vlan through the transit). But when I do a ping to another IP going through an IX the ping only work when I force the source using `-S`: `ping -S $MY_IP $OTHER_IP` . Is there something to do ? How to investigate such issue? > That is expected behavior. I'll explain IPv4 source ip selection shortly. For applications that do not set the source IP address, the source IP is selected at best effort. This "best effort" is choosing a IP nearest (lowest metric) to target. Apparently an IP address on loopback interfaces are "further" than any IP addresses on the outgoing interface. > Is there something to do ? How to investigate such issue? You can refer to RFC 1122 section 3.3.4.3 [1] for IPv4 and RFC 6724 [2] for IPv6. 1. https://datatracker.ietf.org/doc/html/rfc1122#section-3.3.4.3 <https://datatracker.ietf.org/doc/html/rfc1122#section-3.3.4.3> 2. https://datatracker.ietf.org/doc/html/rfc6724 <https://datatracker.ietf.org/doc/html/rfc6724> > > > Benoît > Best regards, Zhenlei [-- Attachment #2 --] <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 11, 2023, at 5:56 PM, Benoit Chesneau <<a href="mailto:benoitc@enki-multimedia.eu" class="">benoitc@enki-multimedia.eu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Is there a way to ensure that the IP set in loopback on the rc.conf is always used as source for routing. I setup it like this:<br class=""><br class="">```<br class="">cloned_interfaces="lo1"<br class="">ifconfig_lo1="inet 195.24.245.226/32 up"<br class="">ifconfig_lo1_ipv6="inet6 2a12:5541:1:1::3/128"<br class="">```<br class=""><br class="">and others IP are set on interfaces or vlans. All routes informations are fetched via BGP. The strange thing is that when I do a ping to `1.1.1.1`` this work (and pass via one of the vlan through the transit). But when I do a ping to another IP going through an IX the ping only work when I force the source using `-S`: `ping -S $MY_IP $OTHER_IP` . Is there something to do ? How to investigate such issue? <br class=""><br class=""></div></div></blockquote><div><br class=""></div><div>That is expected behavior.</div><div><br class=""></div><div>I'll explain IPv4 source ip selection shortly.</div><div>For applications that do not set the source IP address, the source IP is selected at best effort.</div><div>This "best effort" is choosing a IP nearest (lowest metric) to target. Apparently an IP address on</div><div>loopback interfaces are "further" than any IP addresses on the outgoing interface.</div><div><br class=""></div><div><blockquote type="cite" class="">Is there something to do ? How to investigate such issue?</blockquote></div><div>You can refer to RFC 1122 section 3.3.4.3 [1] for IPv4 and RFC 6724 [2] for IPv6.</div><div><br class=""></div><div>1. <a href="https://datatracker.ietf.org/doc/html/rfc1122#section-3.3.4.3" class="">https://datatracker.ietf.org/doc/html/rfc1122#section-3.3.4.3</a></div><div>2. <a href="https://datatracker.ietf.org/doc/html/rfc6724" class="">https://datatracker.ietf.org/doc/html/rfc6724</a></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class=""><br class="">Benoît<br class=""><br class=""></div></div></blockquote></div><br class=""><div class=""> <div>Best regards,</div><div>Zhenlei</div> </div> <br class=""></body></html>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7BA2954F-D9DF-4D95-A8A8-9FF8E1A07E63>
