Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / contrib / ipfilter / man / ipnat.4
1 .\" $FreeBSD: src/contrib/ipfilter/man/ipnat.4,v 1.4.2.1 2001/02/17 20:36:26 darrenr Exp $
2 .\" $DragonFly: src/contrib/ipfilter/man/ipnat.4,v 1.2 2003/06/17 04:24:02 dillon Exp $
3 .TH IPNAT 4
4 .SH NAME
5 ipnat \- Network Address Translation kernel interface
6 .SH SYNOPSIS
7 #include <netinet/ip_compat.h>
8 .br
9 #include <netinet/ip_fil.h>
10 .br
11 #include <netinet/ip_proxy.h>
12 .br
13 #include <netinet/ip_nat.h>
14 .SH IOCTLS
15 .PP
16 To add and delete rules to the NAT list, two 'basic' ioctls are provided
17 for use.  The ioctl's are called as:
18 .LP
19 .nf
20         ioctl(fd, SIOCADNAT, struct ipnat **)
21         ioctl(fd, SIOCRMNAT, struct ipnat **)
22         ioctl(fd, SIOCGNATS, struct natstat **)
23         ioctl(fd, SIOCGNATL, struct natlookup **)
24 .fi
25 .PP
26 Unlike \fBipf(4)\fP, there is only a single list supported by the kernel NAT
27 interface.  An inactive list which can be swapped to is not currently
28 supported.
29
30 These ioctl's are implemented as being routing ioctls and thus the same rules
31 for the various routing ioctls and the file descriptor are employed, mainly
32 being that the fd must be that of the device associated with the module
33 (i.e., /dev/ipl).
34 .LP
35 .PP
36 The structure used with the NAT interface is described below:
37 .LP
38 .nf
39 typedef struct  ipnat   {
40         struct  ipnat   *in_next;
41         void    *in_ifp;
42         u_short in_flags;
43         u_short in_pnext;
44         u_short in_port[2];
45         struct  in_addr in_in[2];
46         struct  in_addr in_out[2];
47         struct  in_addr in_nextip;
48         int     in_space;
49         int     in_redir; /* 0 if it's a mapping, 1 if it's a hard redir */
50         char    in_ifname[IFNAMSIZ];
51 } ipnat_t;
52
53 #define in_pmin         in_port[0]      /* Also holds static redir port */
54 #define in_pmax         in_port[1]
55 #define in_nip          in_nextip.s_addr
56 #define in_inip         in_in[0].s_addr
57 #define in_inmsk        in_in[1].s_addr
58 #define in_outip        in_out[0].s_addr
59 #define in_outmsk       in_out[1].s_addr
60
61 .fi
62 .PP
63 Recognised values for in_redir:
64 .LP
65 .nf
66 #define NAT_MAP         0
67 #define NAT_REDIRECT    1
68 .fi
69 .PP
70 .LP
71 \fBNAT statistics\fP
72 Statistics on the number of packets mapped, going in and out are kept,
73 the number of times a new entry is added and deleted (through expiration) to
74 the NAT table and the current usage level of the NAT table.
75 .PP
76 Pointers to the NAT table inside the kernel, as well as to the top of the
77 internal NAT lists constructed with the \fBSIOCADNAT\fP ioctls.  The table
78 itself is a hash table of size NAT_SIZE (default size is 367).
79 .PP
80 To retrieve the statistics, the \fBSIOCGNATS\fP ioctl must be used, with
81 the appropriate structure passed by reference, as follows:
82 .nf
83         ioctl(fd, SIOCGNATS, struct natstat *)
84
85 typedef struct  natstat {
86         u_long  ns_mapped[2];
87         u_long  ns_added;
88         u_long  ns_expire;
89         u_long  ns_inuse;
90         nat_t   ***ns_table;
91         ipnat_t *ns_list;
92 } natstat_t;
93 .fi
94 .SH BUGS
95 It would be nice if there were more flexibility when adding and deleting
96 filter rules.
97 .SH FILES
98 /dev/ipnat
99 .SH SEE ALSO
100 ipf(4), ipnat(5), ipf(8), ipnat(8), ipfstat(8)