I have an openwrt router with ip 192.168.1.1. What I want to do is to set a proxy server (192.168.1.249) in LAN, and intercepts all communicaitons from two devices (192.168.1.244, 192.168.1.131). The method I use is to set the proxy server as the default gateway, and I configured the following things on my openwrt router.
iptables -t mangle -A PREROUTING -j MARK --set-mark 3 -p tcp -s 192.168.1.131
iptables -t mangle -A PREROUTING -j MARK --set-mark 3 -p tcp -s 192.168.1.244
# Set default gateway as the proxy server in table 2
ip route add default via 192.168.1.249 table 2
# Forward traffic with mark 3 to table 2
ip rule add fwmark 3 table 2
After my test, for all WAN communicaitons of the two devices, the proxy server can intercept them and forward them, it's good. However, I found that these two devices also communicate with each other, and these LAN communications seems not to be forwarded to the proxy server. What is the reason? How can I forward these traffic to the proxy server?
ADDITIONAL TEST: In order to figure out whether configuring iptables is useful, I added a rule for testing:
iptables -t mangle -A PREROUTING -j DROP -s 192.168.1.131
In my opinoin, if this rule works, then the device with ip 244 will not receive any traffic from device with ip 131, and this proves that iptables can work for LAN communication. However, I used the 131 device to send tcp traffic to 244 device, and it works. I doubt that configuring iptables cannot help me forward these LAN traffic to my proxy server. Am I right?