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.
ifconfig is deprecated, but it still works.
The "correct" way would be:
Think I found it, but it might be worth sharing anyway:
I just want to add something on blauwblaatje's answer. https://serverfault.com/a/49651/575693
If you don't put cidr notation, the host will be configured as host only or /32. Hence, you won't be able to communicate with other machine.
Avoid the following example unless you don't need networking. E.g.
same as
Instead, define your subnet based on your requirement, let say Class C or /24
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:
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.