$linuxcli.in _    [commands]    [tips & tricks]    [manpage]    [ESXi CLi]    [what is my ip?]    [pingme!]    [BIOS lock code]    [Code repo]


Assign temporary IP address


To apply changes in machine using below commands make sure you have super user privileges.

Command to add temporary IP address on network interface eth0.

# ifconfig eth0 192.168.1.10 netmask 255.255.255.0
Or
# ip a add 192.168.1.10/24 dev eth0

Command to add default gateway for network interface eth0.

# route add default gw 192.168.1.1
Or
# ip r add 192.168.1.0/24 via 192.168.1.1 dev eth0

Command to verify the IP address has been assigned successfully.

# ifconfig
Or
# ip a

Command to verify the default gateway address assigned successfully.

# route
Or
# ip r

Kindly note this static IP address is assigned for temporary use hence after reboot of machine or restart of network service can loose this static IP address which can be apply again with the above same commands.


Last updated on 30 June 2023 10:43 am IST