Linux ip route matching the source ip

8,280

Solution 1

Yes that's called source routing :

ip rule add from 10.0.0.10 table toto

ip route add default via 88.88.88.88 dev eth1 table toto

You can have more informations here :

source routing in the lartc guide

Solution 2

Any routing decisions based not on destination IP address called PBR (policy-based routing). Usually, PBR is implemented via firewall, so look for possibility to change out interface for packet in iptables.

Share:
8,280

Related videos on Youtube

Henry-Nicolas Tourneur
Author by

Henry-Nicolas Tourneur

Updated on September 17, 2022

Comments

  • Henry-Nicolas Tourneur
    Henry-Nicolas Tourneur over 1 year

    I would like to know if it's possible to tell a Linux kernel to route all packets destinated to X via interface/ip Y but only in case the source IP address would be a specific one.

    Any idea if this is possible?

    Thanks and regards,