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 192.168.2.136 for the nge0
interface using the ifconfig(1M) command:
ifconfig nge0 192.168.2.136 netmask 255.255.255.0
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.
- Remove the file
/etc/dhcp.nge0 . This will prevent dhcpagent(1M) from requesting an IP address using DHCP. - Add the following line to
/etc/hostname.nge0 :
It is important so separate the text into two lines, and it is important to add the192.168.2.136 netmask 255.255.255.0 broadcast + up
up
last, since otherwise the interface will not be brought up. - Add the following line to the
/etc/gateways and/etc/defaultrouter file:192.168.2.1
/etc/defaultrouter file, but it seems like a good idea.
- Reboot the machine:
$ reboot -- -r
- After that, I added the following line to
/etc/inet/ipnodes and/etc/inet/hosts :192.168.2.136 capulet
- ... and last I rebooted the machine a second time to check that all worked.