Link to home
Start Free TrialLog in
Avatar of adroman
adroman

asked on

How to add a persistent static route to Ubuntu 16.04.2 LTS

Dear Colleagues,

I have brand new Ubuntu 16.04.2 LTS and I would like to understand how to add persistent route to it.

For real example I have a default route with metric 100 (see attachment) and I would like to make this route metric to 10.

Please shed some light to undertanding this concept.
default_routing_table.png
Avatar of Rajul Raj
Rajul Raj
Flag of United Arab Emirates image

You can put static routes in /etc/network/interfaces:

auto eth0
iface eth0 inet static
      address 192.168.1.2
      netmask 255.255.255.0
      up route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1
      up route add -net 172.16.0.0 netmask 255.240.0.0 gw 192.168.1.1

Open in new window

Avatar of adroman
adroman

ASKER

Thank you for you answer, but how to configure metric in this file?
Find this example below

auto lo
iface lo inet loopback
auto new0
iface new0 inet static
    address xxx.xxx.xxx.xxx
    netmask xxx.xxx.xxx.xxx
    up route add default gw aaa.aaa.aaa.aaa metric 10
    down route del default gw aaa.aaa.aaa.aaa

auto new1
iface new1 inet static
    address yyy.yyy.yyy.yyy
    netmask yyy.yyy.yyy.yyy
    up route add default gw bbb.bbb.bbb.bbb
    down route del default gw bbb.bbb.bbb.bbb
Avatar of adroman

ASKER

Thank you so much!
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.