route

Manually set IP address and route

Sometimes you need to set a temporarily IP address to your interface.
In this example I need to add 192.168.1.200 to my eth1 interface:

ip addr add 192.168.1.200/24 dev eth0

After this, you also need to set a default route so your computer know where to go if you want to access something outside your subnet:

ip route add default via 192.168.1.1

These settings are not permanent, if you restart your computer, do a dhclient --renew or restart your network, these settings will be gone.

Add a new route to your network configuration

If you want to add a route to a different network enter the following:

sudo route add -net 192.168.2.0 gw 192.168.1.1 netmask 255.255.255.0 dev eth1
  1. 192.168.2.0 = the network you want to route
  2. gw 192.168.1.1 = your current gateway
  3. netmask 255.255.255.0 = your current netmask
  4. dev eth1 = the interface you want to route the 192.168.2.0 over.

To delete the route, enter the following:

sudo route del -net 192.168.2.0 gw 192.168.1.1 netmask 255.255.255.0 dev eth1
Subscribe to RSS - route