That is my iptables config:
Chain PREROUTING (policy ACCEPT 3187 packets, 517K bytes)
pkts bytes target prot opt in out source destination
295 17664 LOG tcp -- wlan0 any anywhere anywhere LOG level warn prefix "REDIRECT: "
420 25164 REDIRECT tcp -- wlan0 any anywhere anywhere redir ports 12345
Chain INPUT (policy ACCEPT 9561 packets, 686K bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 8212 packets, 530K bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 1805 packets, 136K bytes)
pkts bytes target prot opt in out source destination
125 23839 MASQUERADE all -- any eth0 anywhere anywhere
My port is listening:
sudo netstat -tuln | grep 12345
tcp 0 0 127.0.0.1:12345 0.0.0.0:* LISTEN
tcp6 0 0 ::1:12345 :::* LISTEN
My network adapter:
ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.88.18 netmask 255.255.255.0 broadcast 192.168.88.255
inet6 fe80::abd9:66a6:2c42:a8b8 prefixlen 64 scopeid 0x20<link>
ether 2c:cf:67:05:fd:9f txqueuelen 1000 (Ethernet)
RX packets 2123715 bytes 799360843 (762.3 MiB)
RX errors 0 dropped 155 overruns 0 frame 0
TX packets 903629 bytes 147497164 (140.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 1498324 bytes 126327145 (120.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1498324 bytes 126327145 (120.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.4.1 netmask 255.255.255.0 broadcast 192.168.4.255
inet6 fe80::2ecf:67ff:fe05:fda0 prefixlen 64 scopeid 0x20<link>
ether 2c:cf:67:05:fd:a0 txqueuelen 1000 (Ethernet)
RX packets 120878 bytes 25247289 (24.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 150299 bytes 107686413 (102.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan1: flags=4099<UP,BROADCAST,MULTICAST> mtu 2312
ether d8:44:89:de:24:b3 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
when i use curl -x socks5://127.0.0.1:12345 www.google.com
to test, proxy works.
but when i use my ap, the net adapter wlan0 will receive data, but can not redirect data to local port 12345.
I think iptables maybe has problem, who has ideas for this?