42 lines
1.1 KiB
Bash
42 lines
1.1 KiB
Bash
#!/bin/sh
|
|
|
|
tun_iface=tun0
|
|
rtable_id_ingress=100
|
|
rtable_id_egress=101
|
|
rtable_id_ingress6=102
|
|
rtable_id_egress6=103
|
|
|
|
echo 1 > /proc/sys/net/ipv4/ip_forward
|
|
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
|
|
echo 0 > /proc/sys/net/ipv4/tcp_window_scaling
|
|
echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
|
|
|
|
sysctl -w net.ipv4.conf.default.rp_filter=0
|
|
|
|
ip6tables -F
|
|
ip6tables -F -t mangle
|
|
ip6tables -F -t nat
|
|
ip6tables -F -t raw
|
|
|
|
# Create TUN devices
|
|
ip tuntap add dev ${tun_iface} mode tun multi_queue
|
|
ifconfig ${tun_iface} up
|
|
|
|
# IPv6 Default GW
|
|
ip -6 route add default dev ${tun_iface}
|
|
|
|
# Ingress
|
|
ip rule add iif ${tun_iface} tab ${rtable_id_ingress}
|
|
ip route add local default dev lo table ${rtable_id_ingress}
|
|
ip -6 rule add iif ${tun_iface} tab ${rtable_id_ingress6}
|
|
ip -6 route add local default dev lo table ${rtable_id_ingress6}
|
|
|
|
# Egress
|
|
ip rule add fwmark 0x65 lookup ${rtable_id_egress}
|
|
ip route add default dev ${tun_iface} table ${rtable_id_egress}
|
|
#ip -6 rule add fwmark 0x66 lookup ${rtable_id_egress6}
|
|
#ip -6 route add default dev ${tun_iface} table ${rtable_id_egress6}
|
|
|
|
# Flush cache
|
|
ip route flush cache
|