2 # Copyright (C) 2016 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 [[ $EUID == 0 ]] ||
exec sudo
"$BASH_SOURCE" "$@"
18 source /a
/bin
/errhandle
/errcatch-function
19 source /a
/bin
/errhandle
/errallow-function
20 source /a
/bin
/errhandle
/bash-trace-function
25 Usage: mail-route start|stop|show
30 if (( $# != 1 )); then
42 e
() { "$@" ||
printf "maybe ok failure: %s\n" "$*"; }
45 e
() { printf "${0##*/}: %s\n" "$*"; "$@"; }
46 e iptables
-t mangle
-S
49 e ip route show table
1
58 # note, something like this does not work for packets which
59 # exim is replying to. I don't know why.
60 #iptables -t mangle -A OUTPUT -m owner --uid-owner Debian-exim -j MARK --set-mark 0x1
63 e iptables
-t mangle
$iptables_op OUTPUT
-m tcp
-p tcp
-m multiport
--sports 25 -j MARK
--set-mark 0x1
64 e iptables
-t nat
$iptables_op POSTROUTING
-o tun0
-m mark
--mark 0x1 -j SNAT
--to-source 10.8.0.4
65 e ip rule
$ip_op fwmark
1 table
1
66 # note, this rule does not persist when the tun interface is deleted
67 e ip route
$ip_op default via
10.8.0.1 table
1
68 e ip route
$ip_op 192.168.1.0/24 via
192.168.1.1 dev br0 table
1