Does anyone know how to make the following command permanent in Elementary OS?

route add -host dev wlp0s20f3

This route does exactly what I need, but its not permanent. A reboot of the machine or the network connection will result in it being removed from the IP tables.

I can't seem to find the files that define the routes for this device (wifi adapter - wlp0s20f3).

  • Have you tried it with the -p switch? route -p add Commented Jul 13, 2020 at 13:55
  • Google is your friend. networkinghowtos.com/howto/…
    – Sysadmin
    Commented Jul 16, 2020 at 18:17
  • linoxide.com/how-tos/… See the section for Ubuntu. Elementary OS is based in Ubuntu.
    – Sysadmin
    Commented Jul 16, 2020 at 18:20
  • Hi guys - the problem is not how to construct the route, it's that it's temporary. This route works fine. But if i disable/enable the network adapter this route gets removed from the iptables. How can i make this route permanent? (will edit question to make this more clear)
    – BlackSpy
    Commented Jul 17, 2020 at 7:32
  • @Oberleutnant20 I don't see a -p switch listed as an option for route. Is there is link you can share that explains this?
    – BlackSpy
    Commented Jul 17, 2020 at 7:39

1 Answer 1


Type in terminal :

sudo nano /etc/network/interfaces

Add at the bottom this:

up route add -net gw dev wlp0s20f3

Where is the IP of your machine which you can check with command:

ip a

Restart the networking service by typing in terminal:

sudo /etc/init.d/networking restart
  • Thanks so much Sysadmin! it was the up at the front that i was missing :)
    – BlackSpy
    Commented Jul 17, 2020 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.