Step 1. Assign static IP, gateway, broadcast, etc
Edit the file
/etc/network/interfaces
and change as below (say you want to assign static IP to eth0):
auto lo
iface lo inet loopback
# uncomment them if you do hotplug sybsystem
mapping hotplug
script grep
map eth0
auto eth0
iface eth0 inet static
address 192.168.0.200
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
Step 2. Assign name server
Edit the file
/etc/resolv.conf
And put your name server into the file (the example below uses a internal name server at 192.168.0.100):
nameserver 192.168.0.100
Step 3. Stop dhcp client from updating resolv.conf
On an Ubuntu desktop, the dhcp client always update the resolv.conf upon network restart. For a box with static IP, this is not desired. If the package "dhcp-client" or "dhcp3-client" cannot be removed due to dependencies from other package, you can do a hack by editing or creating the file /etc/dhcp3/dhclient-enter-hooks, and add the following content:
make_resolv_conf() {
echo "do nothing with resolv.conf"
}
This works for me on one box, but not the other. I checked and found a file /etc/dhcp3/dhclient-enter-hooks.d/resolvconf, inside which there is a function "make_resolv_conf()". Turning that function into one that does nothing will solve the problem.
Step 4. Restart your network
Just run
# /etc/init.d/networking restart
Then review your network setting:
# ifconfig
Recent comments
2 weeks 5 days ago
3 weeks 6 days ago
7 weeks 4 days ago
32 weeks 4 days ago
33 weeks 3 days ago
44 weeks 3 days ago
45 weeks 5 days ago
1 year 2 weeks ago
1 year 2 weeks ago
1 year 3 weeks ago