Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Feb 2006 08:47:00 -0500
From:      Chuck Swiger <cswiger@mac.com>
To:        Edwin Groothuis <edwin@mavetju.org>
Cc:        freebsd-net@freebsd.org
Subject:   Re: socket / bind - specific address
Message-ID:  <44005FD4.2010100@mac.com>
In-Reply-To: <20060225070722.GA92618@k7.mavetju>
References:  <20060225070722.GA92618@k7.mavetju>

next in thread | previous in thread | raw e-mail | index | archive | help
Edwin Groothuis wrote:
> The situation is as follows:
> 
> We have a couple of FreeBSD routers, with RFC1918 addresses on the
> ethernets and a public address on the loopback. This works fine for
> connecting to the routers, but is problematic for locally originated
> outgoing traffic (think NTP, think syslog): it takes the IP address
> of the outgoing interface, which is the RFC1918 address.

You're giving lo0 a public IP?  Why?

If you want to reach the box via a public IP and are using 1-to-1 NAT
translation to deliver the traffic to one of your NICs using unroutable RFC-1918
addresses, why not configure that NIC to also have the public IP, too?

> Is there a way (sysctl, kernel option) to define which IP address
> is used for locally originated outgoing traffic?

The IP used for locally originated traffic should be governed by the address
specified in the bind() call; if you want that to be different, normally you
configure the associated software being run to use something else.

I don't know how to override the default the kernel hands you if you leave the
decision up to it, short of crafting the packets yourself or using some external
capability like NAT to re-write the addresses being used.

-- 
-Chuck



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?44005FD4.2010100>