themedserv2
January 15th, 2015, 07:29 AM
Hi, I set up ip table bypass with mark and iptables on specifics ports.
It works fine on the ouput for let say port 80:
iptables -t mangle -A OUTPUT -p tcp --dport 80 -j MARK --set-mark 2
iptables --table nat --append POSTROUTING -o eth0 -j MASQUERADE
I put a rule with a custom table:
ip rule add fwmark 2 table 2
Everything works fine here. My table 2 is used when I connect from the inside to any website with port 80, my table main is bypassed and table 2 is used.
-----
When I want to bypass main table on incoming connection to 80 it doesn't work tho.
If I use a rule like this with sport or dport, and I also tried with 443:
sudo iptables -t mangle -A PREROUTING -p tcp --sport 80 -j MARK --set-mark 2
or
sudo iptables -t mangle -A PREROUTING -p tcp --dport 80 -j MARK --set-mark 2
main table is used :(...
All my rp_filter are set to 0 if check this:
sysctl -a | grep \\.rp_filter
All my forwarding are set to 1 if check this:
sysctl -a | grep \\.forwarding
I CAN acces my table 2 via this command. But then, all my connection are going in table 2.. I just want some ports to go in table 2. But with this:
ip rule add from 192.168.2.0/24 table 2
It works! but all my port are bypassing my table 1 and it is not what I want :(
Is there a command I missed or something to enable to Mark a packet on PREROUTING?
When i use tcpdump, i can see the connection trying to get in:
ethertype IPv4 (0x0800), length 66: xx.xxx.x.xx.54052 > 192.168.2.xx.80: Flags [S], seq 1474137113, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
Btw, what is this number: 54052
Thks please help on that!
It works fine on the ouput for let say port 80:
iptables -t mangle -A OUTPUT -p tcp --dport 80 -j MARK --set-mark 2
iptables --table nat --append POSTROUTING -o eth0 -j MASQUERADE
I put a rule with a custom table:
ip rule add fwmark 2 table 2
Everything works fine here. My table 2 is used when I connect from the inside to any website with port 80, my table main is bypassed and table 2 is used.
-----
When I want to bypass main table on incoming connection to 80 it doesn't work tho.
If I use a rule like this with sport or dport, and I also tried with 443:
sudo iptables -t mangle -A PREROUTING -p tcp --sport 80 -j MARK --set-mark 2
or
sudo iptables -t mangle -A PREROUTING -p tcp --dport 80 -j MARK --set-mark 2
main table is used :(...
All my rp_filter are set to 0 if check this:
sysctl -a | grep \\.rp_filter
All my forwarding are set to 1 if check this:
sysctl -a | grep \\.forwarding
I CAN acces my table 2 via this command. But then, all my connection are going in table 2.. I just want some ports to go in table 2. But with this:
ip rule add from 192.168.2.0/24 table 2
It works! but all my port are bypassing my table 1 and it is not what I want :(
Is there a command I missed or something to enable to Mark a packet on PREROUTING?
When i use tcpdump, i can see the connection trying to get in:
ethertype IPv4 (0x0800), length 66: xx.xxx.x.xx.54052 > 192.168.2.xx.80: Flags [S], seq 1474137113, win 8192, options [mss 1460,nop,wscale 2,nop,nop,sackOK], length 0
Btw, what is this number: 54052
Thks please help on that!