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 $
5 ipnat \- Network Address Translation kernel interface
7 #include <netinet/ip_compat.h>
9 #include <netinet/ip_fil.h>
11 #include <netinet/ip_proxy.h>
13 #include <netinet/ip_nat.h>
16 To add and delete rules to the NAT list, two 'basic' ioctls are provided
17 for use. The ioctl's are called as:
20 ioctl(fd, SIOCADNAT, struct ipnat **)
21 ioctl(fd, SIOCRMNAT, struct ipnat **)
22 ioctl(fd, SIOCGNATS, struct natstat **)
23 ioctl(fd, SIOCGNATL, struct natlookup **)
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
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
36 The structure used with the NAT interface is described below:
39 typedef struct ipnat {
40 struct ipnat *in_next;
45 struct in_addr in_in[2];
46 struct in_addr in_out[2];
47 struct in_addr in_nextip;
49 int in_redir; /* 0 if it's a mapping, 1 if it's a hard redir */
50 char in_ifname[IFNAMSIZ];
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
63 Recognised values for in_redir:
67 #define NAT_REDIRECT 1
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.
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).
80 To retrieve the statistics, the \fBSIOCGNATS\fP ioctl must be used, with
81 the appropriate structure passed by reference, as follows:
83 ioctl(fd, SIOCGNATS, struct natstat *)
85 typedef struct natstat {
95 It would be nice if there were more flexibility when adding and deleting
100 ipf(4), ipnat(5), ipf(8), ipnat(8), ipfstat(8)