Configuring for 1 static and 1 DHCP interface ?
Mykola Dzham
i at levsha.me
Tue Nov 23 21:22:00 UTC 2010
Ronald F. Guilmette wrote:
>
> In message <20101123155323.GA51348 at laptop.levsha.me>,
> Mykola Dzham <i at levsha.me> wrote:
>
> > Ronald F. Guilmette wrote:
> >> 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"
> >}
>
> Wow! This is _very_ interesting! How did you know to even suggest this?
> I mean are these things documented on some man page that I mised?
dhclient-enter-hooks referred in dhclient-script(8), functions
add_new_resolv_conf() and add_new_routes() found on
/sbin/dhclient-script (this is shell script)
> Well, anyway, that first part sure sounds like a perfect fix for the
> first of the two issues I described. But as regards to that second
> part, maybe that's doing a but more than what I want.
>
> I don't want the DHCP stuff to set -no- routes at all... I still do
> want it to create a route to 192.168.1.0/24. I just don't want it
> make any change to the default route that would otherwise be set,
> you know, as a result of the defaultrouter= statement in my /etc/rc.conf
> file.
192.168.1.0/24 is interface route. This route installed by ifconfig.
dhclient-script does not install this route manually. So, replacing
add_new_routes() function not affect on 192.168.1.0/24 route.
dhclient-enter-hooks file used only by /sbin/dhclient-script , and
dhclient-script used only by dhclient. So, this is not affect to
settings, set on /etc/rc.conf
> So is there a nice clean & simple way to get the DHCP stuff to only
> create just that route to 192.168.1.0/24 , while leaving the default
> route alone?
Can you try my variant?
> P.S. Oh yea... and one other question... at the top of this new
> /etc/dhclient-enter-hooks file, should I be putting "#!/bin/sh" ?
> Is that OK? Is it needed?
That is ok, but not needed: file sourced into /sbin/dhclient-script
using ``.'' command
--
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