Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a linux server which needs to be set up with production ip address and hostname before installation procedures start (some scripts use these variables).

I've seen somebody assigning a temporary ip address and a temporary gateway simply by typing a couple of commands, but I can't remember.

share|improve this question

ifconfig is deprecated, but it still works.

The "correct" way would be:

sudo ip addr add <extra ip> dev eth0:0
share|improve this answer
+1 for using ip over ifconfig – Coops Aug 4 '09 at 11:11
Depreciated ... where have I been ... – Joseph Kern Aug 4 '09 at 11:45

The command will add an alias to the interface so yes it is in addition to the current one. If you need to add a netmask then the command would look like:

sudo ifconfig eth0:1 <ip> netmask <mask> up

Otherwise ifconfig will use the default for the Class the IP belongs to e.g. for Class C

Just be careful with the default route option. You generally only want one default route so you may want to remove the current default route before adding the new one, otherwise play around with the metric on the route.

share|improve this answer

Think I found it, but it might be worth sharing anyway:

ifconfig eth0:0 <extra ip> up
sudo route add default gw <gatewayip>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.