#!/bin/bash # # This script manually configures routes for the various local networks. # # This script assumes eth0 is configured as: 10.192.64.1/28 # and a default gw of 10.192.64.2 exists for the main routing table. # Also assumes the LAN interface eth1 is configured as: 172.27.1.5/24 # if [ "$IFACE" = lo ]; then exit 0 fi if [ "$IFACE" = eth0 ]; then ip route add 10.192.64.0/28 dev eth0 src 10.192.64.1 table MyTable fi if [ "$IFACE" = eth1 ]; then # Add address to the LAN interface ip addr add 10.27.1.5/24 brd 10.27.1.255 dev eth1 # Set traffic arriving on new IP to go to secondary routing table ip rule add prio 200 from 10.27.1.0/24 lookup MyTable ip rule add prio 301 from 10.192.64.3 lookup MyTable # Set routes for the MyTable table # - setting src here tells which ip to send packets from ip route add 10.27.1.0/24 dev eth1 src 10.27.1.5 table MyTable ip route add 127.0.0.0/8 dev lo table MyTable ip route add default via 10.192.64.2 src 10.192.64.1 table MyTable # Setup the routes bridging computers and phones ip route add 172.27.1.0/24 dev eth1 src 172.27.1.5 table MyTable ip route add 10.27.1.0/24 dev eth1 src 10.27.1.5 table main fi # Flush the route rules to update the kernel ip route flush cache exit 0