Gateway
When I set up my NetBSD system I only added the following to my /etc/rc.conf:dhclient=YESThis worked but after a few days of leaving the system unattended I found that I was unable to ping outside of my network. I was able to fix this by adding a default route:
route add default 192.168.1.1The above is just like the Linux command except 'gw' comes before the IP. The above can be set permanently by adding the following to /etc/rc.conf:
defaultroute="192.168.1.1"Note how this varies across BSDs. In FreeBSD it's defaultrouter (with an 'r' at the end). OpenBSD encourages using /etc/mygate for this setting, which NetBSD supports but recommends using the above instead. "route add default gw 192.168.1.1"
Static IPs
Rather than guess how my hosts have changed based on who booted when, I prefer to hard code IPs. I think I'll run a home DNS server at some point, but for now my small network can just share /etc/host files. It's easy enough to have this kind of set up with a few boxen and a WRT54G. My mac is set with the following:To do something similar in NetBSD I removed the DHCP entry from my /etc/rc.conf and added the following:
ifconfig_fxp0="inet 192.168.1.101 netmask 255.255.255.0"Note that you should also make sure that DHCP is no longer running:
/etc/rc.d/dhclient stop kill `cat /var/run/dhclient.pid`My /etc/resolv.conf was set correctly by DHCP so I don't need to update it. Now I just share my /etc/hosts which I derived from properties of both systems:
# Sat May 19 12:23:11 EDT 2007 ::1 localhost 127.0.0.1 localhost 255.255.255.255 broadcasthost # RFC 1918 specifies that these networks are "internal". # 10.0.0.0 10.255.255.255 # 172.16.0.0 172.31.255.255 # 192.168.0.0 192.168.255.255 192.168.1.100 nenya 192.168.1.101 narya