Žilinská univerzita > Fakulta riadenia a informatiky > Katedra informačných sietí

Setting an IP address using the ip linux command



1) First, we'll check our current status and linux names of interfaces

ip a

or

ip link

where commands lists our' machine network interfaces, for example:

 

2) Next, using the subcommand addr we will add an IP address with a proper nework mask length

ip addr add 192.168.1.10/24 dev [INTERFACE_NAME]

for example:

ip addr add 192.168.1.10/24 dev eth1

 

3) No we will add default gateway's IP address  for correct routing

ip route add default via [GATEWAY_ADDRESS]

in our case for example:

ip route add default via 192.168.1.1

4) and finally start up the interface 

ip link set [INTERFACE_NAME] up

for example for eth1 interface:

ip link set eth1 up

5) And at last, check of corectness:

ip a