wiki:waue/2010/1130
  • /etc/init.d/twocard
#! /bin/sh
### BEGIN INIT INFO
# Provides: single
# Required-Start: $local_fs $all killprocs
# Required-Stop:
# Default-Start: 1
# Default-Stop:
# Short-Description: executed by init(8) upon entering runlevel 1 (single).
### END INIT INFO

PATH=/sbin:/bin

do_start () {
log_action_msg "Two Card Mode ... go"
sh /etc/network/my_bi_ip.sh
}

case "$1" in
start)
do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
exit 3
;;
stop)
# No-op
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac

  • /etc/network/my_bi_ip.sh
#!/bin/bash

IF1=eth1
IP1=140.110.138.193
NT1=140.110.138.0/24
GW1=140.110.138.254

IF2=eth2
IP2=140.110.134.160
NT2=140.110.134.0/24
GW2=140.110.134.254

DGW=${GW1}

ip route add ${NT1} dev ${IF1} src ${IP1} table T1
ip route add default via ${GW1} table T1

ip route add ${NT2} dev ${IF2} src ${IP2} table T2
ip route add default via ${GW2} table T2

ip route add ${NT1} dev ${IF1} src ${IP1}
ip route add ${NT2} dev ${IF2} src ${IP2}

ip route add default via ${DGW}

ip rule add from ${NT1} table T1
ip rule add from ${NT2} table T2

Last modified 14 years ago Last modified on Nov 30, 2010, 5:14:18 PM