I need to add a persistent static route to my Ubuntu 16.04 routing tables that will be saved even if the PC gets restarted. Right now this is the command I'm using and it works fine until I reboot then its not there anymore...
sudo route add -net 10.59.91.192 netmask 255.255.255.192 gw 10.200.0.1 dev wlp3s0
I've seen where people need to set these in /etc/network/interfaces however I believe my interfaces are being managed by Network Manager. Here is my /etc/network/interfaces file...
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
I do have a couple static IPs set which arent shown in the interfaces file which makes me think Network Manager is managing these interfaces so the interfaces file is probably not the place to make these changes.
If anymore information is needed please let me know. Thanks for any help you can give.
In Ubuntu 18.04 or newer you should use Netplan. Add a YAML file to /etc/netplan/, e.g. 99-static-routes.yaml:
network:
version: 2
renderer: networkd
ethernets:
wlps0:
dhcp4: true
routes:
- to: 10.59.91.192/26
via: 10.200.0.1
metric: 5
## Add more routes as needed, e.g.
# - to: 101.102.0.0/16
# via: 192.168.1.254
# metric: 5
Then apply the changes by running `netplan apply` as sudo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With