Apple Mac OS X Server Network Card User Manual


 
Chapter 14 Working with Network Services 237
Port Mapping
You can configure port mapping by adding a redirect_port directive to the
configuration file passed to the natd process. You can accomplish this by editing the
plist version of the configuration file /etc/nat/natd.plist. This file is in turn processed by
the serveradmin tool, and used to create the configuration file /etc/nat/
natd.conf.apple, which is passed to the natd process. See the natd man page for details
about configuring natd.
Note: Don’t edit the /etc/nat/natd.conf.apple file directly, since it is regenerated every
time the serveradmin start nat command is executed.
To configure NAT to use the port mapping rule redirect_port tcp 1.2.3.4:80 80,
you would add the following lines to /etc/nat/natd.plist, inside the configuration
dictionary:
<key>redirect_port</key>
<array>
<dict>
<key>proto</key>
<string>tcp</string>
<key>targetIP</key>
<string>1.2.3.4</string>
<key>targetPortRange</key>
<string>80</string>
<key>aliasPortRange</key>
<string>80</string>
</dict>
</array>
You can then confirm those settings using the serveradmin tool:
$ sudo serveradmin settings nat
...
nat:redirect_port:_array_index:0:proto = "tcp"
nat:redirect_port:_array_index:0:targetPortRange = "80"
nat:redirect_port:_array_index:0:aliasPortRange = "80"
nat:redirect_port:_array_index:0:targetIP = "1.2.3.4"
Control-D
Viewing the NAT Service Log
You can use tail or any other file listing tool to view the contents of the NAT service
log.
To view the latest entries in the log:
$ tail
log-file
You can use the serveradmin getLogPaths command to see where the current NAT
service log is located.