IPNAT(4)                  OpenBSD Programmer's Manual                 IPNAT(4)

NAME
     ipnat - Network Address Translation kernel interface

SYNOPSIS
     #include <netinet/ip_fil_compat.h>
     #include <netinet/ip_fil.h>
     #include <netinets/ip_proxy.h>
     #include <netinet/ip_nat.h>

DESCRIPTION
     Unlike ipf(4),  only a single list is supported by the kernel NAT inter-
     face. An inactive list which can be swapped to is not currently support-
     ed.

     To add/delete rules to/from the NAT list, two ``basic'' ioctl's are pro-
     vided:

           ioctl(fd, SIOCADNAT, struct ipnat *)
           ioctl(fd, SIOCRMNAT, struct ipnat *)

     To retrieve NAT statistics

           ioctl(fd, SIOCGNATS, struct natstat *)

     is provided.

     These ioctl's are implemented as routing ioctl's, so the rules for rout-
     ing ioctl's and the file descriptor fd must be followed.  The most impor-
     tant rule is that the file descriptor fd must be for the device associat-
     ed with the module (i.e., /dev/ipl).

     The structure ipnat and associated macros are defined as:

           typedef struct  ipnat   {
                   struct  ipnat   *in_next;
                   void    *in_ifp;
                   void    *in_apr;
                   u_int   in_space;
                   u_int   in_use;
                   struct  in_addr in_nextip;
                   u_short in_pnext;
                   u_short in_flags;
                   u_short in_port[2];
                   struct  in_addr in_in[2];
                   struct  in_addr in_out[2];
                   int     in_redir;
                   char    in_ifname[IFNAMSIZ];
                   char    in_plabel[APR_LABELLEN];
                   char    in_p;
                   u_short in_dport;
           } ipnat_t;

           #define in_pmin         in_port[0]
           #define in_pmax         in_port[1]
           #define in_nip          in_nextip.s_addr
           #define in_inip         in_in[0].s_addr
           #define in_inmsk        in_in[1].s_addr
           #define in_outip        in_out[0].s_addr
           #define in_outmsk       in_out[1].s_addr

     Where recognised values for in_redir are:

           #define NAT_MAP         0x01
           #define NAT_REDIRECT    0x02
           #define NAT_BIMAP       (NAT_MAP|NAT_REDIRECT)

     The structure natstat is defined as:

           typedef struct  natstat {
                   u_long  ns_mapped[2];
                   u_long  ns_rules;
                   u_long  ns_added;
                   u_long  ns_expire;
                   u_long  ns_inuse;
                   u_long  ns_logged;
                   u_long  ns_logfail;
                   nat_t   **ns_table[2];
                   ipnat_t *ns_list;
                   void    *ns_apslist;
           } natstat_t;

     The NAT kernel tables are hash tables of size NAT_SIZE (default is 367).

FILES
     /dev/ipnat

SEE ALSO
     ipf(1),  ipftest(1),  ipf(4),  ipl(4),  ipf(5),  ipnat(5),  ipnat(8),
     ipfstat(8),  ipmon(8)

     http://coombs.anu.edu.au/~avalon

BUGS
     It would be nice if there were more flexibility when adding and deleting
     filter rules.


OpenBSD 2.6                      June 5, 1999                                2
