This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-kni/run/kni_set_cmd_by_policy_route_v6

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