#!/bin/bash # enable ARP filter for eth0 & eth1 echo "1" > /proc/sys/net/ipv4/conf/eth0/arp_filter echo "1" > /proc/sys/net/ipv4/conf/eth1/arp_filter # create rule for eth0 /sbin/ip rule add from 192.168.127.128 lookup Nic1 /sbin/ip rule add to 192.168.127.128 lookup Nic1 # create rule for eth1 /sbin/ip rule add from 192.168.127.130 lookup Nic2 /sbin/ip rule add to 192.168.127.130 lookup Nic2 # add instructions for eth0 /sbin/ip route flush table Nic1 /sbin/ip route add 192.168.127.128 dev eth0 scope link table Nic1 /sbin/ip route add 192.168.127.0/24 dev eth0 proto kernel scope link src 192.168.127.128 table Nic1 /sbin/ip route add default via 192.168.127.2 dev eth0 table Nic1 # add instructions for eth1 /sbin/ip route flush table Nic2 /sbin/ip route add 192.168.127.130 dev eth1 scope link table Nic2 /sbin/ip route add 192.168.127.0/24 dev eth1 proto kernel scope link src 192.168.127.130 table Nic2 /sbin/ip route add default via 192.168.127.2 dev eth1 table Nic2