Skip to content
Advertisement

Linux – Route Specific Traffic Through Ethernet

At work we have 2 networks; a WiFi one for normal Internet access, and an internal LAN one, for the repo etc. I’ve recently started using Linux and it’s a pain having to constantly switch between cable and WiFi. On Windows, we solved it (so that we can be connected to both network simultaneously) by running the commands:

JavaScript

After running these and connecting to WiFi, everything worked magically. What would the necessary Linux commands be to achieve the same result? I’ve fiddled around a lot with the route command, but haven’t had any luck. Appreciate any help.

EDIT: Here is the output of the route -n command before entering any other commands:

JavaScript

Advertisement

Answer

Variant 1: Direct translation of your solution to linux one

route command:

  • route add -net 10.0.0.0/8 gw 10.18.21.125 metric 40
  • route del default
  • route add default gw 10.18.21.125 metric 40

ip route command:

  • ip route add 10.0.0.0/8 via 10.18.21.125 metric 40
  • ip route del default via 10.18.21.125
  • ip route add default via 10.18.21.125 metric 40

add launch of these command after wifi would be connected or to startup script.

Variant 2. Turn magic off 🙂

  • turn route of 10.0.0.0 network via your LAN interface using command like this: ip route add 10.0.0.0/8 via 10.18.21.125 metric 10. In that case all traffic would be routed via default interface, except 10.0.0.0/8 network.
  • increase priority for default wifi route, if he is lower than LAN one

PS. Possibly this question should be placed on Server Fault site 🙂

EDIT: according to provided route map

  • route del default
  • route add default gw [wifi gateway ip]
  • route add -net 10.0.0.0/8 gw 10.18.21.125
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement