From: "kaiwen" Date: Wed, 14 Jan 2004 08:07:18 +0000 Subject: [LARTC] Precedence of iptables chain, local routing table and newly created routing table Message-Id: MIME-Version: 1 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0124_01C3DAB8.7BF72D20" List-Id: To: lartc@vger.kernel.org This is a multi-part message in MIME format. ------=_NextPart_000_0124_01C3DAB8.7BF72D20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi,=20 I been trying on ip rule fwmark and iptables MARK.=20 I will show my testing in detail, but my ultimate question is why ONLY = marking in Mangle OUTPUT tables works, but not others? Network Diagram ------------ 192.168.250.197 eth0 LINUX ROUTER eth1 192.168.8.88 = ------------------ 192.168.8.112 eth0 Windows XP Client Steps (performed on LINUX ROUTER) (1) Delete route to 192.168.8.0 from local routing table on (2) Add route to 192.168.8.0 at table test2 (3) Mark packet with --set-mark 3 at MANGLE OUTPUT table (4) Forward all packet marked 3 to table test2 using ip rule fwmark (5) Do a ip ro flush cache (6) Ping from 192.168.8.112 to 192.168.8.88 is successful [root@son-ag webauth]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use = Iface 192.168.250.0 0.0.0.0 255.255.255.0 U 0 0 0 = eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 = lo 0.0.0.0 192.168.250.254 0.0.0.0 UG 0 0 0 = eth0 [root@son-ag webauth]# ip route show table test2 192.168.8.0/24 via 192.168.8.88 dev br0 [root@son-ag webauth]# iptables -t mangle -L Chain OUTPUT (policy ACCEPT) target prot opt source destination MARK all -- anywhere anywhere MARK set 0x3 [root@son-ag webauth]# ip ru 0: from all lookup local 32764: from all fwmark 3 lookup test2 32766: from all lookup main 32767: from all lookup 253 I wish to know why is that ONLY marking at OUTPUT table works? The network setup is for testing purpose, I wish to know the precedence = of iptables chains, local routing table and newly created table (e.g. = test2) Looking at the iptables chain diagram, my guess is MARKING at mangle = INPUT or mangle PREROUTING should work as well.=20 When packet comes off from wire, I mark it with 3 at mangle PREROUTING. = Since it is a ping to 192.168.8.88, it should be a local process. Then the ping is successful. But from my testing, no.=20 Another possiblity is packet is route to test2 routing table after = mangle OUTPUT and before mandle POSTROUTING. I am getting confuse :) Please advice. Thank you Kaiwen ------=_NextPart_000_0124_01C3DAB8.7BF72D20 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
I been trying on ip rule fwmark and = iptables MARK.=20
 
I will show my testing in detail, but = my ultimate=20 question is why ONLY marking in Mangle OUTPUT tables works, but not=20 others?
 
Network Diagram
 
------------ 192.168.250.197 eth0 LINUX = ROUTER eth1=20 192.168.8.88 ------------------ 192.168.8.112 eth0 Windows XP=20 Client
 
Steps (performed on LINUX = ROUTER)
(1) Delete route to 192.168.8.0 from = local routing=20 table on
(2) Add route to 192.168.8.0 at table=20 test2
(3) Mark packet with --set-mark 3 at = MANGLE OUTPUT=20 table
(4) Forward all packet marked 3 to = table test2=20 using ip rule fwmark
(5) Do a ip ro flush cache
(6) Ping from 192.168.8.112 to = 192.168.8.88 is=20 successful
 
 
[root@son-ag webauth]# route = -n
Kernel IP=20 routing table
Destination    =20 Gateway        =20 Genmask         Flags Metric=20 Ref    Use Iface
192.168.250.0  =20 0.0.0.0        =20 255.255.255.0   U    =20 0      = 0        0=20 eth0
127.0.0.0      =20 0.0.0.0        =20 255.0.0.0       U    =20 0      = 0        0=20 lo
0.0.0.0         = 192.168.250.254=20 0.0.0.0         = UG   =20 0      = 0        0=20 eth0
 
[root@son-ag webauth]# ip route show = table=20 test2
192.168.8.0/24 via 192.168.8.88 dev br0
 
[root@son-ag webauth]# iptables -t = mangle=20 -L
Chain OUTPUT (policy=20 ACCEPT)
target     prot opt=20 source           &= nbsp;  =20 destination
MARK       all  = -- =20 anywhere           = ; =20 anywhere           = MARK set=20 0x3
 
[root@son-ag webauth]# ip=20 ru
0:      from all lookup = local
32764: =20 from all fwmark        3 lookup=20 test2
32766:  from all lookup main
32767:  from all = lookup=20 253
 
I wish to know why is that ONLY marking = at OUTPUT=20 table works?
The network setup is for testing = purpose, I wish to=20 know the precedence of iptables chains, local routing table and = newly=20 created table (e.g. test2)
 
Looking at the iptables chain diagram, = my guess is=20 MARKING at mangle INPUT or mangle PREROUTING should work as well. =
When packet comes off from wire, I mark = it with 3=20 at mangle PREROUTING. Since it is a ping to 192.168.8.88, it should be a = local=20 process.
Then the ping is successful. But from = my testing,=20 no.
 
Another possiblity is packet is route = to test2=20 routing table after mangle OUTPUT and before mandle POSTROUTING. I am = getting=20 confuse :)
 
Please advice. Thank you
 
Kaiwen
------=_NextPart_000_0124_01C3DAB8.7BF72D20-- _______________________________________________ LARTC mailing list / LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/mailman/listinfo/lartc HOWTO: http://lartc.org/