EXAMPLES
This section deals with the map command and its variations.
To change IP#s used internally from network 10 into an ISP provided 8 bit subnet at 209.1.2.0 through the ppp0 interface, the following would be used:
map ppp0 10.0.0.0/8 -> 209.1.2.0/24
The obvious problem here is were trying to squeeze over 16,000,000 IP addresses into a 254 address space. To increase the scope, remapping for TCP and/or UDP, port remapping can be used;
map ppp0 10.0.0.0/8 -> 209.1.2.0/24 portmap tcp/udp 1025:65000
which falls only 527,566 addresses short of the space available in network 10. If we were to combine these rules, they would need to be specified as follows:
map ppp0 10.0.0.0/8 -> 209.1.2.0/24 portmap tcp/udp 1025:65000
map ppp0 10.0.0.0/8 -> 209.1.2.0/24
so that all TCP/UDP packets were port mapped and only other protocols, such as ICMP, only have their IP# changed. In some instances, it is more appropriate to use the keyword auto in place of an actual range of port numbers if you want to guarantee simultaneous access to all within the given range. However, in the above case, it would default to 1 port per IP address, since we need to squeeze 24 bits of address space into 8. A good example of how this is used might be:
map ppp0 172.192.0.0/16 -> 209.1.2.0/24 portmap tcp/udp auto
which would result in each IP address being given a small range of ports to use (252). In all cases, the new port number that is used is deterministic. That is, port X will always map to port Y. WARNING: It is not advisable to use the auto feature if you are maping to a /32 (i.e. 0/32) because the NAT code will try to map multiple hosts to the same port number, outgoing and ultimately this will only succeed for one of them. The problem here is that the map directive tells the NAT code to use the next address/port pair available for an outgoing connection, resulting in no easily discernible relation between external addresses/ports and internal ones. This is overcome by using map-block as follows:
map-block ppp0 172.192.0.0/16 -> 209.1.2.0/24 ports auto
For example, this would result in 172.192.0.0/24 being mapped to 209.1.2.0/32 with each address, from 172.192.0.0 to 172.192.0.255 having 252 ports of its own. As opposed to the above use of map , if for some reason the user of (say) 172.192.0.2 wanted 260 simultaneous connections going out, they would be limited to 252 with map-block but would just move on to the next IP address with the map command. /dev/ipnat /etc/services /etc/hosts
SEE ALSO
ipnat (4), hosts (5), ipf (5), services (5), ipf (8), ipnat (8)