Skip to contentSkip to conversation

How to add nat rules by another loadable kernel module

DISCUSSION andre achternaam 1 participant 1 message Oct 25, 2002 netfilter

lore
Share & tools
lore
#0 lore raw

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

_________________________________________________________________
Surf the Web without missing calls! Get MSN Broadband. http://resourcecenter.msn.com/access/plans/freeactivation.asp