From nobody Wed Feb 15 23:22:40 2023 X-Original-To: freebsd-questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PHDdJ273pz3rTlb for ; Wed, 15 Feb 2023 23:22:44 +0000 (UTC) (envelope-from johnl@iecc.com) Received: from gal.iecc.com (gal.iecc.com [IPv6:2001:470:1f07:1126:0:43:6f73:7461]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "gal.iecc.com", Issuer "Let's Encrypt Authority X3" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PHDdJ1MHNz3ssM for ; Wed, 15 Feb 2023 23:22:44 +0000 (UTC) (envelope-from johnl@iecc.com) Authentication-Results: mx1.freebsd.org; none Received: (qmail 21933 invoked from network); 15 Feb 2023 23:22:42 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=iecc.com; h=date:message-id:from:to:cc:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:cleverness; s=55aa.63ed6942.k2302; bh=6hGUzMSmFS0Gvi70WMksh/ubQ+ZiC9vxxtIoq3vooCE=; b=dOke+pGLL3gqwoL/zozjCXGiwN8YCaNYRf4acuYCwTG+AAB/V7O0y8FwN8st7sJ1PXODAANoIvqyH2g8RsXubzGhcPEWbhQCnysjkxelF288zogO9Zyy4JmC8WgcPV7nNshlL7cjdOdbhuwKfXyCsZcVg+5mGiNRHZR4QunPXhGG+Y1UutsFIcT5QUWaxikWTDJzUS4sW1r+I/yXINuOaHTqjjBJB+hbMgPWTUf42GI/VgcbXUNS8kW3aKsJS/cP0LjugfYFdNVcPC4ODy5UN/jNnrM/Qmnd3NoROJIG+qWwX8yap7EF0J7k+sOEGJlN9WkDxL+ys+L7Xbxlgx31aw== Received: from ary.qy ([IPv6:2001:470:1f07:1126::78:696d:6170]) by imap.iecc.com ([IPv6:2001:470:1f07:1126::78:696d:6170]) with ESMTPS (TLS1.3 ECDHE-RSA AES-256-GCM AEAD) via TCP6; 15 Feb 2023 23:22:42 -0000 Received: by ary.qy (Postfix, from userid 501) id 5A86B9977DF3; Wed, 15 Feb 2023 18:22:40 -0500 (EST) Date: 15 Feb 2023 18:22:40 -0500 Message-Id: <20230215232241.5A86B9977DF3@ary.qy> From: "John Levine" To: freebsd-questions@freebsd.org Cc: possessor.assizer305@aceecat.org Subject: Re: Source IP selection In-Reply-To: <20230215222458.bij5oh3wtaq6inje@beesty.loosely.org> Organization: Taughannock Networks X-Headerized: yes Cleverness: minimal List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org Mime-Version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 8bit X-Rspamd-Queue-Id: 4PHDdJ1MHNz3ssM X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N It appears that Ian Zimmerman said: >On Wed, Feb 15, 2023 at 04:45:19PM -0500, John Levine wrote: >> >how is the source IP address selected for an unbound socket, if there >> >are multiple addresses (ie. aliases) configured on the outgoing >> >interface? I am interested in particular in the UDP case, ie. >> >the sendto() syscall. >> >This is almost the question at the following link but ... not about >> >THAT kernel but FreeBSD. >> > >> >https://stackoverflow.com/questions/63955841/how-does-tcp-ip-select-a-source-ip-address >> >> Same answer, use bind() if you want to bind to a specific address. > >Let me ask a little more specifically then :) > >May the kernel choose an address through which there's no route to >the destination? It knows what addreses it has configured on what interfaces, and what's in its local routing table, not the entire state of the global Internet. The routing table just tells it what interface to use for what networks. I think it does soemthing simple minded like using the first address configured on the interface if you don't override that with bind(). If you bind a local address and then tell it to send to a remote address that isn't in the routing table for the interface the address is assigned to, I have no idea what happens. Try it and let us know what happens. If you told us what you are trying to do, you would get more useful answers. R's, John