Configuring for 1 static and 1 DHCP interface ?

Mykola Dzham i at levsha.me
Tue Nov 23 16:28:03 UTC 2010


 Ronald F. Guilmette wrote:
> 
> I just recently re-jigged my main server/workstation so that instead
> of just having a single interface that talks to the Internet via a
> single static IP, it now has, in addition to that, one other interface
> (and card) that's talking to one of those little black&blue Linksys
> router thingies to which other machines on my local network are connected
> (all using DHCP which is implemented in the Linksys box).
> 
> For most stuff the default routing should be out via the original interface
> (and its static IP) but when the main server/workstation wants to talk
> to anything in 192.168.1.0/24, it should instead route those packets
> via the second/newer interface over to the Linksys box, i.e. so that
> this main machine can talk to other stuff on the local network.
> 
> So anyway, here's what I have now in my /etc/rc.conf file:
> 
> defaultrouter="69.62.255.254"
> network_interfaces="fxp0 rl0 lo0 auto"
> ifconfig_fxp0="inet 69.62.255.118 netmask 255.255.255.0"
> ifconfig_rl0="DHCP"
> 
> This is problematic for several reasons.  First, as I have learned,
> having any interface set to "DHCP" in the /etc/rc.conf file causes
> all sorts of DHCP magic to happen at startup time, and the end result
> of all that magic is that two undesirable things happen:
> 
>    1)  The /etc/resolv.conf file gets replaced with something that
>        causes DNS resolutions to go someplace other than where I want
>        them to go, and...
> 
>    2)  the default route that I attempted to set in the /etc/rc.conf
>        file gets clobbered and replaced by a default route obtained
>        from the DHCP negotiation on the second interface.

You can totally disable resolv.conf changing and rote setting: put into
/etc/dhclient-enter-hooks file this code:

add_new_resolv_conf() {
	echo "doing nothing to resolv.conf"
}

add_new_routes() {
	echo "do not set routes"
}

-- 
LEFT-(UANIC|RIPE)
JID: levsha at jabber.net.ua
PGP fingerprint: 1BCD 7C80 2E04 7282 C944  B0E0 7E67 619E 4E72 9280


More information about the freebsd-net mailing list