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

iAmoric
  • 121
  • 1
  • 4

1 Answers1

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.

Knobee
  • 357
  • 2
  • 7
  • 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 09:29
  • What is your SSH client IP? If it were in the enp3s0 net, you would not need additional routes. – John Mahowald 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 08:15