-
Notifications
You must be signed in to change notification settings - Fork 0
/
tunel_client_setupwifi.bash
executable file
·26 lines (20 loc) · 1.15 KB
/
tunel_client_setupwifi.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
#https://aftermanict.blogspot.com.es/2015/11/bash-iptables-iproute2-and-multiple.html
#http://themediaserver.com/bypass-vpn-connections-specifics-ports-ubuntu-kodibuntu/
#echo "1 primary" >> /etc/iproute2/rt_tables
#echo "2 secondary" >> /etc/iproute2/rt_tables
TUNINT=$1
sudo iptables -A OUTPUT -t mangle -p tcp --dport 80 -j MARK --set-mark 1
sudo iptables -A OUTPUT -t mangle -p tcp --dport 8080 -j MARK --set-mark 2
sudo ip rule add from all fwmark 1 table 1
sudo ip rule add from all fwmark 2 table 2
sudo ip route flush cache
# A default route should exist in the main routing table as well
#sudo ip route add default via 127.0.1.1
sudo ip route add table primary default via 192.168.200.1
sudo ip route add table secondary default via 192.168.10.1
sudo iptables -t nat -A POSTROUTING -o wlxe894f61567de -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -o $TUNINT -j MASQUERADE
#Copy other routes to the new tables
#ip route show table main | grep -Ev ^default | while read ROUTE ; do sudo ip route add table primary $ROUTE; done
#ip route show table main | grep -Ev ^default | while read ROUTE ; do sudo ip route add table secondary $ROUTE; done