How to route only specific subnet (source ip) to a particular interface?
OS: Linux
I know I can do easily by dest ip by using something like route add 1.2.3.4/24 dev eth4 but I do not see how can route based on source ip.
|
How to route only specific subnet (source ip) to a particular interface? I know I can do easily by dest ip by using something like
| |||||
feedback
|
|
You need to use policy based routing. Something kind of like
This pretty much says, that all traffic from (can't test it ATM but i believe it's pretty much right :) ) | |||||
feedback
|
|
http://www.wlug.org.nz/SourceBasedRouting This site has a nice example of source based routing. | |||
|
feedback
|
|
You must use the route command. For example if you want to route all ip of 192.168.1.xxx to a particular device you have to use the following command:
With that command you say that all the packets sent from that subnet must be sent to the eth0 interface. If you need to add also a gateway for that connection you can use that:
| |||||||||||||||
feedback
|