All of lore.kernel.org
 help / color / mirror / Atom feed
From: luoqiang <luoqiang@ict.ac.cn>
To: netfilter-devel@lists.samba.org
Cc: luoqiang@ict.ac.cn
Subject: conntrack/NAT module
Date: Mon, 3 Jun 2002 12:06:38 +0800	[thread overview]
Message-ID: <02060312063802.01904@luoqiang> (raw)

Hi,all

Sorry to resend this mail,last mail is not can be seen.
I am writing a DNAT module to achieve the purpose which is  identical to
 "iptables -A PREROUTING -t nat -p udp -d 159.226.1.1 --dport 5000 -j DNAT 
--to 192.168.1.2:5000".

host A-------------------------------->host 
B------------------------------------->host C
159.226.1.2--------------->159.226.1.1/192.168.1.1--------------->192.168.1.2

I have read the hacking howto and have finished the conntrack module,which 
can be seen in "proc/net/ip_conntrack" 
file of host B as"EXPECTING : proto=17 src=0 dst=159.226.1.1 sport=0 
dport=5000"
But something wrong in my nat module.
After loaded the module, no DNAT happened. :-(
there are some questions I don't understand.
1.what's the function of foo_help in struct ip_nat_helper?I do nothing here.
2. what's the function of struct ip_nat_multi_range here?what's the function  
   of struct ip_nat_range range[0] and  struct ip_nat_range range[1]?(I don't 
   know what's the meaning of " hangs off end. ")
3.how to configure the struct ip_nat_multi_range when do DNAT?
4.if I want to close the port after open it in a module,how I can do?


my code is here:
......
  static int foo_nat_expected(struct sk_buff **pksb,
                          unsigned int hooknum,
                          struct ip_conntrack *ct,
                          struct ip_nat_info *info,
                          struct ip_conntrack *master,
                          struct ip_nat_info *masterinfo,
                          unsigned int *verdict)
 
  {
     struct ip_nat_multi_range mr;
     u_int32_t newdstip = 0x0201a8c0;
     if (HOOK2MANIP(hooknum)==IP_NAT_MANIP_DST){        
  
     mr.rangesize=1;
     mr.range[0].flags = IP_NAT_RANGE_PROTO_SPECIFIED;   //  I don't know 
what's the meaning here
     mr.range[0].min = mr.range[0].max = ((union 
ip_conntrack_manip_proto){htons(5000)});
     mr.range[0].min_ip=mr.range[0].max_ip=newdstip;

     *verdict = ip_nat_setup_info(ct,&mr,hooknum);

     return 1;
     }
  }

Thanks in advance,
luoqiang

luoqiang@ict.ac.cn

             reply	other threads:[~2002-06-03  4:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-03  4:06 luoqiang [this message]
2002-06-04  7:56 ` conntrack/NAT module Harald Welte
  -- strict thread matches above, loose matches on Subject: below --
2002-06-05  2:36 luoqiang
2002-06-09 17:30 ` Harald Welte
2002-06-01 11:05 luoqiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02060312063802.01904@luoqiang \
    --to=luoqiang@ict.ac.cn \
    --cc=netfilter-devel@lists.samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.