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