| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# to be used in network setup scripts, e.g: |
| 4 |
# /etc/network/interfaces |
| 5 |
# |
| 6 |
# iface eth0 inet dhcp |
| 7 |
# post-up /usr/local/sbin/setup-cross-routing-per-interface 12 eth1 |
| 8 |
# |
| 9 |
# iface eth1 inet dhcp |
| 10 |
# post-up /usr/local/sbin/setup-cross-routing-per-interface 11 eth0 |
| 11 |
# |
| 12 |
|
| 13 |
if_a=$IFACE |
| 14 |
gw_a=$(grep "option routers" /var/lib/dhcp/dhclient.$if_a.leases | sed -e 's/[^0-9.]//g' | tail -1) |
| 15 |
|
| 16 |
table_to=$1 |
| 17 |
shift |
| 18 |
|
| 19 |
if_b=$1 |
| 20 |
shift |
| 21 |
|
| 22 |
ip route add table $table_to default via $gw_a dev $if_a |
| 23 |
ip rule add iif $if_b table $table_to prio 1000 |
| 24 |
sysctl -w "net.ipv4.conf.$if_a.forwarding=1" |