Last active 1743538528

Позволят направить в туннель сломанные IP-диапазоны

setup_split_tunneling.sh Raw
1# RT Table Configuration
2echo "228 warp_table" >> /etc/iproute2/rt_tables
3uci add network rt_table
4uci set network.@rt_table[-1].name='warp_table'
5uci set network.@rt_table[-1].id='228'
6
7# IPv4 Rule and Route Configuration
8uci add network rule
9uci set network.@rule[-1].mark='0xe4'
10uci set network.@rule[-1].lookup='warp_table'
11
12uci add network route
13uci set network.@route[-1].interface='WARP'
14uci set network.@route[-1].target='0.0.0.0/0'
15uci set network.@route[-1].table='warp_table'
16
17# IPv6 Rule and Route Configuration
18uci add network rule6
19uci set network.@rule6[-1].lookup='warp_table'
20uci set network.@rule6[-1].mark='0xe4'
21
22uci add network route6
23uci set network.@route6[-1].interface='WARP'
24uci set network.@route6[-1].target='::/0'
25uci set network.@route6[-1].table='warp_table'
26
27# Firewall Rules Configuration
28uci add firewall rule
29uci set firewall.@rule[-1].name='Mark-Amazon-Traffic'
30uci set firewall.@rule[-1].ipset='Amazon_CIDRs'
31uci set firewall.@rule[-1].target='MARK'
32uci set firewall.@rule[-1].set_mark='0xe4'
33uci set firewall.@rule[-1].src='lan'
34uci set firewall.@rule[-1].dest='*'
35uci set firewall.@rule[-1].priority='1'
36uci set firewall.@rule[-1].chain='prerouting'
37uci set firewall.@rule[-1].family='ipv4'
38
39# Amazon IP Sets
40# Download & parse like this: curl https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[].ip_prefix' | tee amazon-ip-ranges.txt
41uci add firewall ipset
42uci set firewall.@ipset[-1].name='Amazon_CIDRs'
43uci set firewall.@ipset[-1].family='ipv4'
44uci set firewall.@ipset[-1].match='dest_net'
45uci set firewall.@ipset[-1].loadfile='/etc/luci-uploads/amazon-ip-ranges.txt'
46
47# Hetzner IPv4 IP Sets
48uci add firewall ipset
49uci set firewall.@ipset[-1].name='Hetzner_CIDRs_v4'
50uci set firewall.@ipset[-1].family='ipv4'
51uci set firewall.@ipset[-1].match='dest_net'
52uci set firewall.@ipset[-1].entry='116.202.0.0/16' '116.203.0.0/16' '128.140.0.0/17' '135.181.0.0/16' '136.243.0.0/16' '138.199.128.0/17' '138.201.0.0/16' '139.28.242.0/23' '142.132.128.0/17' '144.76.0.0/16' '148.251.0.0/16' '157.180.0.0/17' '157.90.0.0/16' '159.69.0.0/16' '162.55.0.0/16' '167.233.0.0/16' '167.235.0.0/16' '168.119.0.0/16' '171.25.225.0/24' '176.9.0.0/16' '178.212.75.0/24' '178.63.0.0/16' '185.107.52.0/22' '185.126.28.0/22' '185.157.176.0/23' '185.157.178.0/23' '185.157.83.0/24' '185.171.224.0/22' '185.189.228.0/24' '185.189.229.0/24' '185.189.230.0/24' '185.189.231.0/24' '185.213.45.0/24' '185.216.237.0/24' '185.226.99.0/24' '185.228.8.0/23' '185.50.120.0/23' '188.245.0.0/16' '188.34.128.0/17' '188.40.0.0/16' '193.110.6.0/23' '193.163.198.0/24' '194.42.180.0/22' '194.42.184.0/22' '194.62.106.0/24' '195.201.0.0/16' '195.248.224.0/24' '195.60.226.0/24' '197.242.84.0/22' '201.131.3.0/24' '204.29.146.0/24' '213.133.96.0/19' '213.239.192.0/18' '216.55.108.0/22' '23.88.0.0/17' '37.27.0.0/16' '45.145.227.0/24' '46.4.0.0/16' '46.62.128.0/17' '49.12.0.0/16' '49.13.0.0/16' '5.75.128.0/17' '5.9.0.0/16' '65.108.0.0/16' '65.109.0.0/16' '65.21.0.0/16' '78.138.62.0/24' '78.46.0.0/15' '85.10.192.0/18' '88.198.0.0/16' '88.99.0.0/16' '91.107.128.0/17' '91.190.240.0/21' '91.99.0.0/16' '94.130.0.0/16' '95.216.0.0/16' '95.217.0.0/16'
53
54# Hetzner IPv6 IP Sets
55uci add firewall ipset
56uci set firewall.@ipset[-1].name='Hetzner_CIDRs_v6'
57uci set firewall.@ipset[-1].family='ipv6'
58uci set firewall.@ipset[-1].match='dest_net'
59uci set firewall.@ipset[-1].entry='2a01:4f8::/32' '2a01:4f9::/32' '2a06:be80::/29' '2a0e:7700::/32' '2a11:e980::/29' '2a12:1fc0::/42'
60
61# Hetzner IPv4 Marking Rule
62uci add firewall rule
63uci set firewall.@rule[-1].name='Mark-Hetzner-IPv4'
64uci set firewall.@rule[-1].family='ipv4'
65uci set firewall.@rule[-1].src='lan'
66uci set firewall.@rule[-1].ipset='Hetzner_CIDRs_v4'
67uci set firewall.@rule[-1].target='MARK'
68uci set firewall.@rule[-1].set_mark='0xe4'
69uci set firewall.@rule[-1].chain='prerouting'
70uci set firewall.@rule[-1].dest='*'
71
72# Hetzner IPv6 Marking Rule
73uci add firewall rule
74uci set firewall.@rule[-1].name='Mark-Hetzner-IPv6'
75uci set firewall.@rule[-1].family='ipv6'
76uci set firewall.@rule[-1].src='lan'
77uci set firewall.@rule[-1].ipset='Hetzner_CIDRs_v6'
78uci set firewall.@rule[-1].target='MARK'
79uci set firewall.@rule[-1].set_mark='0xe4'
80uci set firewall.@rule[-1].chain='prerouting'
81uci set firewall.@rule[-1].dest='*'
82
83# Apply changes
84uci commit network
85uci commit firewall
x_result_example.txt Raw
1network.@rt_table[0]=rt_table
2network.@rt_table[0].name='warp_table'
3network.@rt_table[0].id='228'
4network.@rule[0]=rule
5network.@rule[0].mark='0xe4'
6network.@rule[0].lookup='warp_table'
7network.@route[0]=route
8network.@route[0].interface='WARP'
9network.@route[0].target='0.0.0.0/0'
10network.@route[0].table='warp_table'
11network.@rule6[0]=rule6
12network.@rule6[0].lookup='warp_table'
13network.@rule6[0].mark='0xe4'
14network.@route6[0]=route6
15network.@route6[0].interface='WARP'
16network.@route6[0].target='::/0'
17network.@route6[0].table='warp_table'
18firewall.@rule[11]=rule
19firewall.@rule[11].name='Mark-Amazon-Traffic'
20firewall.@rule[11].ipset='Amazon_CIDRs'
21firewall.@rule[11].target='MARK'
22firewall.@rule[11].set_mark='0xe4'
23firewall.@rule[11].src='lan'
24firewall.@rule[11].dest='*'
25firewall.@rule[11].priority='1'
26firewall.@rule[11].chain='prerouting'
27firewall.@rule[11].family='ipv4'
28firewall.@ipset[2]=ipset
29firewall.@ipset[2].name='Amazon_CIDRs'
30firewall.@ipset[2].family='ipv4'
31firewall.@ipset[2].match='dest_net'
32firewall.@ipset[2].loadfile='/etc/luci-uploads/amazon-ip-ranges.txt' # Скачал & спарсил с https://ip-ranges.amazonaws.com/ip-ranges.json
33firewall.@ipset[3]=ipset
34firewall.@ipset[3].name='Hetzner_CIDRs_v4'
35firewall.@ipset[3].family='ipv4'
36firewall.@ipset[3].match='dest_net'
37firewall.@ipset[3].entry='116.202.0.0/16' '116.203.0.0/16' '128.140.0.0/17' '135.181.0.0/16' '136.243.0.0/16' '138.199.128.0/17' '138.201.0.0/16' '139.28.242.0/23' '142.132.128.0/17' '144.76.0.0/16' '148.251.0.0/16' '157.180.0.0/17' '157.90.0.0/16' '159.69.0.0/16' '162.55.0.0/16' '167.233.0.0/16' '167.235.0.0/16' '168.119.0.0/16' '171.25.225.0/24' '176.9.0.0/16' '178.212.75.0/24' '178.63.0.0/16' '185.107.52.0/22' '185.126.28.0/22' '185.157.176.0/23' '185.157.178.0/23' '185.157.83.0/24' '185.171.224.0/22' '185.189.228.0/24' '185.189.229.0/24' '185.189.230.0/24' '185.189.231.0/24' '185.213.45.0/24' '185.216.237.0/24' '185.226.99.0/24' '185.228.8.0/23' '185.50.120.0/23' '188.245.0.0/16' '188.34.128.0/17' '188.40.0.0/16' '193.110.6.0/23' '193.163.198.0/24' '194.42.180.0/22' '194.42.184.0/22' '194.62.106.0/24' '195.201.0.0/16' '195.248.224.0/24' '195.60.226.0/24' '197.242.84.0/22' '201.131.3.0/24' '204.29.146.0/24' '213.133.96.0/19' '213.239.192.0/18' '216.55.108.0/22' '23.88.0.0/17' '37.27.0.0/16' '45.145.227.0/24' '46.4.0.0/16' '46.62.128.0/17' '49.12.0.0/16' '49.13.0.0/16' '5.75.128.0/17' '5.9.0.0/16' '65.108.0.0/16' '65.109.0.0/16' '65.21.0.0/16' '78.138.62.0/24' '78.46.0.0/15' '85.10.192.0/18' '88.198.0.0/16' '88.99.0.0/16' '91.107.128.0/17' '91.190.240.0/21' '91.99.0.0/16' '94.130.0.0/16' '95.216.0.0/16' '95.217.0.0/16'
38firewall.@ipset[4]=ipset
39firewall.@ipset[4].name='Hetzner_CIDRs_v6'
40firewall.@ipset[4].family='ipv6'
41firewall.@ipset[4].match='dest_net'
42firewall.@ipset[4].entry='2a01:4f8::/32' '2a01:4f9::/32' '2a06:be80::/29' '2a0e:7700::/32' '2a11:e980::/29' '2a12:1fc0::/42'
43firewall.@rule[12]=rule
44firewall.@rule[12].name='Mark-Hetzner-IPv4'
45firewall.@rule[12].family='ipv4'
46firewall.@rule[12].src='lan'
47firewall.@rule[12].ipset='Hetzner_CIDRs_v4'
48firewall.@rule[12].target='MARK'
49firewall.@rule[12].set_mark='0xe4'
50firewall.@rule[12].chain='prerouting'
51firewall.@rule[12].dest='*'
52firewall.@rule[13]=rule
53firewall.@rule[13].name='Mark-Hetzner-IPv6'
54firewall.@rule[13].family='ipv6'
55firewall.@rule[13].src='lan'
56firewall.@rule[13].ipset='Hetzner_CIDRs_v6'
57firewall.@rule[13].target='MARK'
58firewall.@rule[13].set_mark='0xe4'
59firewall.@rule[13].chain='prerouting'
60firewall.@rule[13].dest='*'