Skip to contentSkip to conversation

Need fast reply: how does iptables interact with kernel space code ??

DISCUSSION Sergei Lavrov 2 participants 2 messages Mar 17, 2007 – Apr 2, 2007 netfilter

lore
Share & tools
lore
#0 lore raw

Hi,

I went through some of the iptables code because I want to understand how iptables interact with the kernel space.

For example, the following command redirects all the web traffic to the local port 10080.

iptables -t nat -A PREROUTING -i ppp0 -p tcp -j REDIRECT --to-port 10080 --dport 80

I went through extensions/ipt_REDIRECT.c and libiptc/libiptc.c and libiptc/libip4tc.c.

But I still don't understand what iptables does to the kernel so that the kernel will redirect the traffic ? Exactly, what does iptables communicate to the kernel ? Can someone explain the gist to me ??

For understanding of the kernel side, should I read iptable_filter.c, ip_nat_standalone.c, or ip_nat_rule.c ??

Thanks,

Sergei

____________________________________________________________________________________
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367

#1 lore raw

lör 2007-03-17 klockan 07:39 -0700 skrev Sergei Lavrov:

Quoted 8 lines

iptables -t nat -A PREROUTING -i ppp0 -p tcp -j
REDIRECT --to-port 10080 --dport 80

I went through extensions/ipt_REDIRECT.c and
libiptc/libiptc.c and libiptc/libip4tc.c.

But I still don't understand what iptables does to the kernel so that the kernel will redirect the traffic ?

The above communicates a NAT mapping to the netfilter NAT kernel when the rule fires. See the netfilter hacking howto and the kernel side of the REDIRECT target (net/ipv4/netfilter/ipt_REDIRECT.c) for valuable insight in how this works in the kernel.

Quoted 1 line

Can someone explain the gist to me ??

Not entirely sure which part you want explained. There is very many components involved.

There is

* Linux TCP/IP stack
* Netfilter hooks in the above
* conntrack
* NAT
* iptables, with it's different tables, matches and targets
* and the iptables userspace command with extensions matching the same
as above..

Regards
Henrik