Changing from a DHCP to static setup is easy:
Open the network interface configuration file:
sudo nano /etc/network/interfaces
Depending on the number of network interfaces in your machine, this file will have some sections that start with eth0 or eth1. "eth0" Refers to your primary network interface. My default config file looked like this for eth0:
auto eth0 iface eth0 inet dhcp
This is the configuration for a dynamic (DHCP) configuration. To change your eth0 to have a static ip address assigned to it, change the config to look like this:
auto eth0 iface eth0 inet static address 192.168.0.2 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 gateway 192.168.0.1
The IP address of my server is 192.168.0.2, the one on my router (the gateway) is 192.168.0.1. I've read somewhere that you must also change the IP that is configured for your nameserver in the /etc/resolv.conf file. But my nameserver configuration was set to my router (192.168.0.1) and my router has nameservers configured. It worked for me this way, so I didn't touch it. You can check if your server's namerserver configuration is working by pinging a domain "ping somedomain.com" (after restarting the network).
Finally, restart the network to let the changes come into effect.
sudo /etc/init.d/networking restart
Setting up Wake On LAN.
My server is located in the garage, tucked away out of sight. As I mentioned in earlier posts, I want to have this server as energy friendly as possible. I don't like paying for many idle CPU cycles on my electricity bill. So I turn on the server only when I need it during the day or evening. To avoid walking to the garage each time I need the server, I made sure I bought a motherboard that supported Wake On LAN (WOL). This way I can boot the server over the network from a client machine.
The configuration of WOL on Ubuntu is fairly easy.
First figure out on what network interface (eth0, eth1, ...) you need to enable WOL. You can have an overview of your network interfaces if you type the "ifconfig" command in your console:
eth0 Link encap:Ethernet HWaddr 00:11:22:33:44:55 inet addr:192.168.0.2 Bcast:192.168.0.255 Mask:255.255.255.0 ....
In my case, I wanted WOL on eth0. Please notice also the "HWaddr" in the console output. the 00:11:22:33:44:55 value is the "MAC address" of your network interface card. This you will need later on to actually "wake up" your server from a client machine.
Good, now let's add the wakeonlan configuration file to the Ubuntu 8.04.1 system:
cd /etc/init.d sudo nano wakeonlanconfig
Add the following lines to it and save the file.
#!/bin/bash ethtool -s eth0 wol g exit
After the file is created, make sure it has the right permissions from the /etc/init.d directory:
sudo chmod a+x wakeonlanconfig
Make sure that the script runs on startup of your machine:
update-rc.d -f wakeonlanconfig defaults
In my case that was it, WOL is configured now.
I always shutdown my server using the following command:
sudo halt
**Note** in order for this to work, you possibly need to configure your BIOS settings to enable WOL for your network device. Check the manual of your motherboard to figure out the settings.
Now that your server is shutdown, on your client machine, in my case a Windows box, you must make use of the MAC address (see above 00:11:22:33:44:55) of your server network interface in order to send the server it's wakeup call.
I can't really recommend a specific tool for that (I use a simple freeware from Depicus), but if you search Google for "WOL" and/or "magic packet sender" it will give you a list of possibilities. All tools come down to one thing: filling in the MAC address and/or IP address of your server and firing the magic packets of over the network. Depending on the boot-up time of your server, it will be available a few minutes later.