4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
5 m
() { printf "%s\n" "$*"; "$@"; }
11 # wait up to 10 seconds for the gateway to appear
12 for i
in in {1.
.10}; do
13 gw
=$
(/usr
/sbin
/ip route |
sed -rn 's/^default via .* dev (\S+).*/\1/p')
20 echo $0: error
: couldnt
find gateway interface
in 10 seconds
>&2
26 m
/sbin
/iptables
-t nat
$cmd PREROUTING
-i $gw -p tcp
-m tcp
--dport $port -j DNAT
--to-destination 10.8.0.4
27 m
/sbin
/ip6tables
-t nat
$cmd PREROUTING
-i $gw -p tcp
-m tcp
--dport $port -j DNAT
--to-destination 2600:3c00
:e002
:3800::4
29 # for bk to talk to MAIL_HOST, only need port 25.
30 ip6tables
-t nat
$cmd PREROUTING
-i $ifname -s 2600:3c00
:e002
:3800::5 -d 2600:3c00
:e000
:280::2 -p tcp
-m tcp
--dport 25 -j DNAT
--to-destination 2600:3c00
:e002
:3800::4
31 # we could leave these on all the time but its convenient to do it here
32 m
/sbin
/iptables
$cmd FORWARD
-i $ifname -o $gw -j ACCEPT
33 m
/sbin
/iptables
$cmd FORWARD
-i $gw -o $ifname -j ACCEPT
37 /sbin
/iptables
-t nat
$cmd POSTROUTING
-s 10.8.0.0/24 -o $gw -j MASQUERADE
38 /sbin
/ip6tables
-t nat
$cmd POSTROUTING
-s 2600:3c00
:e002
:3800::/64 -o $gw -j MASQUERADE
47 do-forward
-A ${ports[@]}
50 do-forward
-D ${ports[@]}
53 echo "$0: error: expected 1 argument of start or stop"