1

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.

5

ifconfig is deprecated, but it still works.

The "correct" way would be:

sudo ip addr add <extra ip> dev eth0:0
  • +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
1

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

ifconfig eth0:0 <extra ip> up
sudo route add default gw <gatewayip>
0

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. 255.255.255.0 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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