I was just asked to add a new IP address to a Debian cloud host. It’s a simple thing, but depending on how often – or how seldom – you do it, you often still need to look it up to remind yourself. So, having previously decided to do a post every time I do something like this (for my own benefit as much as anything) here’s what I did…
Edit /etc/network/interfaces
– obviously you’ll need to be root or sudo
it.
There will probably something like this in there:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
The first chunk is the loopback interface, but the second chunk is the ethernet (eth0
). The final line might be dhcp
or it might be static
, followed by more lines to describe the IP, like this:
iface eth0 inet static
address 209.85.147.147
netmask 255.255.255.255
To add a new IP – let’s imagine it’s ‘209.85.147.148’ – to the same ethernet interface, just add something like this:
iface eth0:0 inet static
address 209.85.147.148
netmask 255.255.255.255
The “:0
” is the extra bit we added. Then restart your networking:
/etc/init.d/networking restart
(keeping your fingers crossed you didn’t make any mistakes that might then lock you out of your host completely, of course ;)