How do I set the source address on a multi-homed host?

Ted Mittelstaedt tedm at
Sat Feb 19 07:46:31 GMT 2005

> -----Original Message-----
> From: owner-freebsd-questions at
> [mailto:owner-freebsd-questions at]On Behalf Of Daniela
> Sent: Tuesday, February 15, 2005 1:30 PM
> To: Jan Grant
> Cc: Alin-Adrian Anton; questions at
> Subject: Re: How do I set the source address on a multi-homed host?
> >
> > Having said that: technically, you specify source addresses for
> > connections by calling bind(2) prior to calling connect(2). 
> If you fail
> > to do this, the operating system will select a source IP address for
> > you. This'll often be the IP of the outgoing interface.
> Well, if the OS selects the source IP, can't I just modify the 
> code that 
> selects it? Will this work all the time, or just when the 
> application lets 
> the OS select an address for it?


  I have a FreeBSD 4 system setup as a NAT router, (it's real name is that has 2 interfaces, the inside
is, the outside is

  This is in fact a real live system and I'm using it right now.

  I have several FreeBSD systems on the 192.168.1 network on the
inside, and several FreeBSD systems on the 65.75.197 network on the

  If I log into (doesen't matter
what interface I connect to) and I initiate a Telnet session from to a system on the 192.168.1 network,
once I'm logged into that system, issuing a "w -n" command shows me
logged in from

  If on the other hand I log into a FreeBSD system that is on the
65.75.197 network, and issue a "w -n" command, then it shows me as
being logged in from

  If your setup isn't doing this, then it's screwed.  If it IS working
this way and you think there's something wrong, then it is you that
are screwed. :-)

  Could you confirm behavior one way or another - up until now the
explanations and your responses have been extremely fuzzy (open to
a number of different interpretations)


More information about the freebsd-questions mailing list