Sunday, January 14, 2007

Setting static IP for a small home network

I have an US Robotics router (USR805461), which is great in many ways except one: there is no MAC-based assignment of IP:s using DHCP... and the port forwarding (and every other feature of the router, with a few exceptions) is based on using IP addresses. So, in order to get port forwarding to work, I need to assign a static IP to the computer. No big deal, I thought, but there were some complications resulting from bad descriptions that could have been avoided if I hadn't been trying to do it to fast.

Since I previously used DHCP, the computer was already configured for using this. It was easy enough to change the IP address to for the nge0 interface using the ifconfig(1M) command:

ifconfig nge0 netmask
Then I wanted to make it persistent over reboots, and that's where I had a bit of trouble. After unsuccessfully following some instructions in various articles, I did the following to assign a static IP address to the computer.
  1. Remove the file /etc/dhcp.nge0. This will prevent dhcpagent(1M) from requesting an IP address using DHCP.
  2. Add the following line to /etc/hostname.nge0:
    netmask broadcast + up
    It is important so separate the text into two lines, and it is important to add the up last, since otherwise the interface will not be brought up.
  3. Add the following line to the /etc/gateways and /etc/defaultrouter file:
    I don't know if it is necessary to add it to the /etc/defaultrouter file, but it seems like a good idea.
Now I want to give the computer the name "capulet", which means adding lines in the files /etc/inet/ipnodes and /etc/inet/hosts, but since DHCP has been adding info there already, I needed to reboot the machine before making the changes. It appears that I have to do this so that DHCP can remove the entries in an orderly fashion (I tried to make the changes below before rebooting the machine, but they disappeared during the reboot). So, the next step is:
  1. Reboot the machine:
    $ reboot -- -r
  2. After that, I added the following line to /etc/inet/ipnodes and /etc/inet/hosts: capulet
  3. ... and last I rebooted the machine a second time to check that all worked.
Now all works find, except that the router seems to have problems with serving DNS queries: the router "hangs" after running a while, and the only way I have managed to get it back in shape is by rebooting the router. I'm either going to make the Solaris machine be the DNS server for the network (while could be a problem since it means keeping it up at all times), or at least configure it to use a DNS server that actually works.