Networking Forums

Networking Forums > Computer Networking > Linux Networking > iptables and routing

Reply
Thread Tools Display Modes

iptables and routing

 
 
Prashant Jois
Guest
Posts: n/a

 
      04-29-2009, 09:15 PM
Hello,

I've been experimenting with routing using the netfilter mark value
(the MARK target extension). Say I have to computers A and B, with IP
addresses 192.168.1.101 and 192.168.1.102, respectively. I use
computer A to SSH into computer B on port 22.

My "main" routing table on computer B is empty. In additional I have
another table "999" on computer B, with the following route:

192.168.1.101 dev eth0 scope link

In my IP rules, I have the following:

0: from all lookup local
32765: from all lookup 999
32766: from all lookup main
32767: from all lookup default

At this point I'm able to SSH from A to B successfully.

Now I add the following routing using iptables:

iptables -t mangle -A OUTPUT -j MARK --set-mark 0x4

my OUTPUT chain is listed as follows:

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
MARK all -- anywhere anywhere MARK set
0x4

I then change my IP rules so that I have the following:

0: from all lookup local
32765: from all fwmark 0x4 lookup 999
32766: from all lookup main
32767: from all lookup default

I expect this to forward all packets generated by local applications
to be marked with 0x4, and then have all these packets routed through
eth0 (via table 999). Thus, I'm expecting my SSH connection to stay
up at this point. However, the connection hangs, meaning the packets
are not being routed properly.

What am I doing wrong here?

Thanks,

Prashant
 
Reply With Quote
 
 
 
 
Pascal Hambourg
Guest
Posts: n/a

 
      05-01-2009, 01:40 PM
Hello,

Prashant Jois a écrit :
>
> I then change my IP rules so that I have the following:
>
> 0: from all lookup local
> 32765: from all fwmark 0x4 lookup 999
> 32766: from all lookup main
> 32767: from all lookup default
>
> I expect this to forward all packets generated by local applications
> to be marked with 0x4, and then have all these packets routed through
> eth0 (via table 999). Thus, I'm expecting my SSH connection to stay
> up at this point. However, the connection hangs, meaning the packets
> are not being routed properly.


When the packet is to be generated, before being sent through the OUTPUT
chains, it has no mark yet, thus no applicable route if the 'main'
routing table is empty. An applicable route must exist for the packet to
be first generated. Then routing can be altered with a mark.
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Routing with iptables Jozza Linux Networking 7 03-24-2009 03:33 PM
iptables email routing Brian Ronk Linux Networking 1 04-07-2007 01:09 AM
routing between public IP's using iptables sandeepagarwal.1980@gmail.com Linux Networking 2 05-30-2005 05:00 AM
Need Heldp :Iptables Routing ! Filip Lyncker Linux Networking 0 11-20-2004 03:20 PM
iptables MARK and Routing Steve Wakelin Linux Networking 0 07-01-2004 12:06 AM



1 2 3 4 5 6 7 8 9 10 11