1

I have a Ubuntu device connected to two different networks:

  • enp3s0 (10.131.140.0/22), wired and connected to a local network (no access to internet)
  • wlp4s0 (172.29.0.0/16), wireless and connected to internet.

I would like every packets with destination 10.131.140.0/22 go through the enp3s0 interface, whereas all other packets go with wlp4s0 interface.

How can I do that?

In my route table I have two default routes:

default via 10.131.143.254 dev enp3s0  proto static  metric 100
default via 172.29.0.1 dev wlp4s0  proto static  metric 600

Thanks

3

As long as you have the correct netmasks set on the interfaces, locally destination packets will "do the right thing".

To get "everything else" to go out the wlp4s0 interface, you will need to remove the default route pointing to the enp3s0 interface.

3
  • I'm connected to the device with SSH using the local network (so with enp3s0 interface). If I delete the default route to this interface, i'm not able to connect with SSH anymore.. Also, if I reboot the device, this route is going back as default with the other to wlp4s0
    – iAmoric
    Dec 18 '19 at 9:29
  • What is your SSH client IP? If it were in the enp3s0 net, you would not need additional routes. Dec 18 '19 at 14:57
  • Yes it's enp3s0. The SSH client is in the 10.131.140.0/22 network
    – iAmoric
    Dec 19 '19 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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