How to add nat rules by another loadable kernel module
Hi coders,
I'm developing a module, but have some difficulty with it. May be some of you can put me on the right track. In my loadable kernel module i want to add the following rule to my nat module(s):
iptables -t nat -A PREROUTING -d 192.168.0.50 -i eth0 -j DNAT --to-destination 10.255.255.10
I'm aware this is a userspace methode to do it, and i like to know how to do this in kernel space. I have looked hours in all kind of netfilter files but i don't have any hint how to do it.
Q] Can somebody tell me how to add NAT rules from another loadable kernel module or provide some example code?
I don't want to do it with the register_expect stuff since you need a releted (master) connection, which i dont have. Of couse later on i want to delete them as wel with the following look-a-like
iptables -t nat -D PREROUTING -d 192.168.0.50 -i eth0 -j DNAT --to-destination 10.255.255.10
Thanx in advance for the information.
Andre Kleibeuker
_________________________________________________________________
Choose an Internet access plan right for you -- try MSN! http://resourcecenter.msn.com/access/plans/default.asp
Quoted 4 lines · andre achternaam
I'm aware this is a userspace methode to do it, and i like to know how to do this in kernel space. I have looked hours in all kind of netfilter files but i don't have any hint how to do it.
The answer will not satisfy you:
You don't do this in kernel space. There is no API for doing this, and no
code inside the kernel which can actually create ip_tables. Everything is in libiptc in userspace.
Quoted 1 line
Andre Kleibeuker
Signature · 5 lines
Live long and prosper - Harald Welte / [email protected] http://www.gnumonks.org/ ============================================================================ "If this were a dictatorship, it'd be a heck of a lot easier, just so long as I'm the dictator." -- George W. Bush Dec 18, 2000