ipset 设置:
ipset create non-vpn hash:net
ipset add non-vpn 1.0.1.0/24
ipset add non-vpn 1.0.2.0/23
ipset add non-vpn 1.0.8.0/21
ipset add non-vpn 1.0.32.0/19
ipset add non-vpn 1.1.0.0/24
ipset add non-vpn 1.1.2.0/23
ipset add non-vpn 1.1.4.0/22
...
iptables 设置:
iptables -F
iptables -X
iptables -Z
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
iptables -t nat -A POSTROUTING -o eth0 -m set --match-set non-vpn dst -j MASQUERADE
iptables -t nat -A POSTROUTING -o tun0 -m set ! --match-set non-vpn dst -j MASQUERADE
route 信息:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
10.8.0.0 * 255.255.255.0 U 0 0 0 tun0
外网 IP 192.168.1.1 255.255.255.255 UGH 0 0 0 eth0
127.0.0.1 192.168.1.1 255.255.255.255 UGH 0 0 0 eth0
128.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.6.0 * 255.255.255.0 U 0 0 0 br-lan
ifconfig 网卡信息:
br-lan Link encap:Ethernet HWaddr ********
inet addr:192.168.6.1 Bcast:192.168.6.255 Mask:255.255.255.0
inet6 addr: fd74:b959:13de::1/60 Scope:Global
inet6 addr: fe80::457:2ff:fe85:67ce/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:30679 errors:0 dropped:0 overruns:0 frame:0
TX packets:40267 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2791569 (2.6 MiB) TX bytes:37067870 (35.3 MiB)
eth0 Link encap:Ethernet HWaddr ********
inet addr:192.168.1.30 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::4cac:92ff:fe35:c480/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:42954 errors:0 dropped:1830 overruns:0 frame:0
TX packets:31589 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40242889 (38.3 MiB) TX bytes:5667545 (5.4 MiB)
Interrupt:31
eth1 Link encap:Ethernet HWaddr********
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:30751 errors:0 dropped:0 overruns:0 frame:0
TX packets:40261 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3225443 (3.0 MiB) TX bytes:37067141 (35.3 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:43483 errors:0 dropped:0 overruns:0 frame:0
TX packets:43483 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:42440596 (40.4 MiB) TX bytes:42440596 (40.4 MiB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.2 P-t-P:10.8.0.2 Mask:255.255.255.0
inet6 addr: fe80::ae94:5ef8:ae8e:4cea/64 Scope:Link
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:14631 errors:0 dropped:0 overruns:0 frame:0
TX packets:9002 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:15496526 (14.7 MiB) TX bytes:829920 (810.4 KiB)
================================================================================
想通过 iptables 实现 ipset 列表的 ip(强内)走 eth0 出去
其余 ip(强外)走 tun0 实现饭强。
现在是非 ipset 的 ip 列表可以走 tun0 成功饭强,但是 ip 列表走 eth0 失败,不通,请问一下问题出在哪里?
ipset create non-vpn hash:net
ipset add non-vpn 1.0.1.0/24
ipset add non-vpn 1.0.2.0/23
ipset add non-vpn 1.0.8.0/21
ipset add non-vpn 1.0.32.0/19
ipset add non-vpn 1.1.0.0/24
ipset add non-vpn 1.1.2.0/23
ipset add non-vpn 1.1.4.0/22
...
iptables 设置:
iptables -F
iptables -X
iptables -Z
iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
iptables -t nat -A POSTROUTING -o eth0 -m set --match-set non-vpn dst -j MASQUERADE
iptables -t nat -A POSTROUTING -o tun0 -m set ! --match-set non-vpn dst -j MASQUERADE
route 信息:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
10.8.0.0 * 255.255.255.0 U 0 0 0 tun0
外网 IP 192.168.1.1 255.255.255.255 UGH 0 0 0 eth0
127.0.0.1 192.168.1.1 255.255.255.255 UGH 0 0 0 eth0
128.0.0.0 10.8.0.1 128.0.0.0 UG 0 0 0 tun0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
192.168.6.0 * 255.255.255.0 U 0 0 0 br-lan
ifconfig 网卡信息:
br-lan Link encap:Ethernet HWaddr ********
inet addr:192.168.6.1 Bcast:192.168.6.255 Mask:255.255.255.0
inet6 addr: fd74:b959:13de::1/60 Scope:Global
inet6 addr: fe80::457:2ff:fe85:67ce/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:30679 errors:0 dropped:0 overruns:0 frame:0
TX packets:40267 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2791569 (2.6 MiB) TX bytes:37067870 (35.3 MiB)
eth0 Link encap:Ethernet HWaddr ********
inet addr:192.168.1.30 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::4cac:92ff:fe35:c480/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:42954 errors:0 dropped:1830 overruns:0 frame:0
TX packets:31589 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40242889 (38.3 MiB) TX bytes:5667545 (5.4 MiB)
Interrupt:31
eth1 Link encap:Ethernet HWaddr********
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:30751 errors:0 dropped:0 overruns:0 frame:0
TX packets:40261 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3225443 (3.0 MiB) TX bytes:37067141 (35.3 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:43483 errors:0 dropped:0 overruns:0 frame:0
TX packets:43483 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:42440596 (40.4 MiB) TX bytes:42440596 (40.4 MiB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.2 P-t-P:10.8.0.2 Mask:255.255.255.0
inet6 addr: fe80::ae94:5ef8:ae8e:4cea/64 Scope:Link
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:14631 errors:0 dropped:0 overruns:0 frame:0
TX packets:9002 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:15496526 (14.7 MiB) TX bytes:829920 (810.4 KiB)
================================================================================
想通过 iptables 实现 ipset 列表的 ip(强内)走 eth0 出去
其余 ip(强外)走 tun0 实现饭强。
现在是非 ipset 的 ip 列表可以走 tun0 成功饭强,但是 ip 列表走 eth0 失败,不通,请问一下问题出在哪里?
