Subject: Starting dhclient and ipnat at boot time
To: None <>
From: Marc Baudoin <>
List: tech-net
Date: 01/15/1999 22:02:23
Content-Type: text/plain; charset=us-ascii


I'm connected to the Internet at home via a cable modem hooked to
my cable TV plug.

IP addresses are allocated by DHCP.  That's OK since NetBSD ships
dhclient by default (FreeBSD does not and a friend of mine had to
install their dhcp package, that doesn't ship the
/etc/dhclient-script file, that he had to get from the ISC dhcp
sources, a bad point for FreeBSD...).

I also use ipnat to set up some basic NAT rules so I can use my
laptop to also access the Internet (the computer that is
connected to the cable modem has two Ethernet board, pretty
standard setup).

Although both dhclient and ipnat are shipped with the standard
NetBSD installation, there's no way other way to start them at
boot time except to launch them from /etc/rc.local. That's fine
for me but dhclient and ipnat can be widely used and it would be
interesting if the standard /etc/rc stuff could be able to launch
them (they already do dhcp server and ipf).

I thought it would be consistent to start them from /etc/netstart
but /usr and /var are not mounted when /etc/netstart is launched
(they're mounted right after it) and dhclient needs to write the
/var/db/dhclient.leases file and ipnat is located in /usr/sbin.

So I modified my /etc/rc.conf file to include two new variables
and /etc/rc to launch dhclient and ipnat as needed (though I'm
not particularly happy with them being launched from /etc/rc
instead of /etc/netstart).  The corresponding patch is attached.
It sure needs some polish but I consider including something like
this in a future NetBSD version would be a good thing.

Marc Baudoin   -=-   <>

Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch

--- /etc/rc.conf.orig	Wed Jan 13 21:09:03 1999
+++ /etc/rc.conf	Thu Jan 14 21:53:09 1999
@@ -30,9 +30,11 @@
 # Networking startup
 ipfilter=NO					# uses /etc/ipf.conf
+ipnat=YES					# uses /etc/ipnat.conf
 ipmon=NO		ipmon_flags="-sn"	# syslog ipfilter messages
 auto_ifconfig=YES				# config all avail. interfaces
 net_interfaces=""				# used only if above is NO
+dhclient=YES					# may use /etc/dhclient.conf
 flushroutes=YES					# flush routes in netstart
 ntpdate=YES		ntpdate_hosts=""	# blank: hosts in /etc/ntp.conf
 ppp_peers=""					# /etc/ppp/peers to call
--- /etc/rc.orig	Wed Jan 13 21:22:37 1999
+++ /etc/rc	Thu Jan 14 22:02:15 1999
@@ -118,6 +118,26 @@
+if checkyesno dhclient; then
+	dhclient
+if checkyesno ipnat; then
+	if [ -f /etc/ipnat.conf ]; then
+		if checkyesno ipfilter; then
+			# ipfilter already initialized, do nothing
+		else
+			ipf -E
+		fi
+		echo 'installing NAT rules ... '
+		ipnat -C -f /etc/ipnat.conf
+	else
+		echo
+		echo "WARNING: /etc/ipnat.conf not readable " \
+		    "ipnat not started."
+	fi
 # "Critical" file systems are now mounted.  Go ahead and swap
 # to files now, since they will be residing in the critical file
 # systems (or, at least, better).