HEV

Linux simple source policy routing

· hev

Dual network connections

eth0

  • Address: 192.168.0.2
  • NetMask: 255.255.255.0
  • Gateway: 192.168.0.1

eth1

  • Address: 192.168.1.2
  • NetMask: 255.255.255.0
  • Gateway: 192.168.1.1

Routing policy

  • Transmit via eth0 when source address is 192.168.0.2
  • Transmit via eth1 when source address is 192.168.1.2

Commands

# eth0
ifconfig eth0 192.168.0.2/24 up
ip rule add from 192.168.0.2 table 251
ip route add default via 192.168.0.1 dev eth0 src 192.168.0.2 table 251

# eth1
ifconfig eth1 192.168.1.2/24 up
ip rule add from 192.168.1.2 table 252
ip route add default via 192.168.1.1 dev eth1 src 192.168.1.2 table 252