Subject: Re: dhclient -and- dhcp server in same box?
To: NetBSD netbsd-help mailing list <netbsd-help@netbsd.org>
From: Julian Coleman <jdc@coris.org.uk>
List: netbsd-help
Date: 10/10/2003 11:00:07
> I have DSL that gives me one IP address via DHCP.
> 
> But I have several other machines that I would like to either assign
> permanent non-routable addresses or have them be "local clients" to
> my internal net getting their IP info via DHCP.
> 
> I'd like all the machines to have Internet access through the main
> NetBSD box (which has 2 ethernet interfaces - one that connects to the
> DSL modem, the other that connects to a switch that has all my other
> local machines.)

For both dhclient and dhcpd, you can specify the interface(s) to use.
Assuming le0 for the external interface and le1 for the internal one,
you could add:

  dhclient=YES		dhclient_flags="le0"
  dhcpd=YES		dhcpd_flags="-q le1"

to /etc/rc.conf.  Assuming 192.168.104.0 is your internal network: set
this box to have 192.168.104.1 and your /etc/dhcpd.conf could give out
addresses in this network range with 192.168.104.1 as the gateway (and
possibly name server).

For the internal machines to access the Internet, set up NAT.   Something
like:

  map le0 192.168.13.0/24 -> 0/32 portmap tcp/udp 2000:60000
  map le0 192.168.13.0/24 -> 0/32

in you /etc/ipnat.conf should work for this (and add ipnat to /etc/rc.conf).
If you run `/usr/sbin/ipnat -F` when you receive an IP address via DHCP,
this will make sure that connections keep running if you receive a different
IP address.  Something like:

  case "$reason" in
  BOUND|REBOOT)
	/usr/sbin/ipnat -F
  	;;
  esac

in /etc/dhclient-exit-hooks should do that (see /sbin/dhclient-script).

J

-- 
                    My other computer also runs NetBSD
                          http://www.netbsd.org/