NAT (Network Address Translation) for BeOS
by Richard Burgess
rickb@spy.net
www.rickb.com

This net_server add-on allows your BeOS computer to serve as an Internet 
router. Unlike the existing IP Forwarding network feature,  NAT allows you 
to use a single assigned IP Address to service all the machines
on your network. That means, for example, that you could connect over
a PPP connection and all the machines on your network
could access the Internet without the need to obtain addresses for 
each one from your service provider. It is similiar to Linux's 
IP-Masquerade and BSD's own NAT feature.

Installing
With the current version of the BeOS (R4),  you will need to put the nat add-on 
in /boot/beos/system/add-ons/net_server. 

Next you will need to edit /boot/home/config/settings/network.
First, edit the  PROTOCOLS line in the GLOBAL: section and add "nat" the list 
of existing protocols. If the line does not exist create one like this:

	PROTOCOLS = "nat"

Next, add a new section at the bottom of the file, configuring to your setup. 

For example, if your ppp device is specified in the network file
as modem0 and your local ethernet interface is interface0:

nat:
	LOCAL = interface0
	INTERNET = modem0

There are additional configuration options that are not required, but which you
can tweak if you want. Defaults that NAT uses if you don't specify them are 
shown in the following examples:
	START_PORT = 30000		Start of ports that NAT will use for address mapping
	END_PORT = 60000		End of ports that NAT will use for address mapping
	PORT_TIMEOUT = 600		Time (in minutes) that a port used for mapping will time out
	SOCKET_TIMEOUT = 1		Time (in minutes) after which sockets reserved for NAT but
							unused will be reclaimed by the system
	SOCKET_POOL_SIZE = 5	The size of the pool of sockets reserved and ready for use.
	
Once this is done, go to the network preferences and restart networking,
making sure the IP Forwarding checkbox is checked.

Currently Tested and Supported Protocols/Apps:
HTTP, POP, SMTP, NNTP, telnet, FTP in passive mode
and probably others. The main criteria is if the protocol uses
port numbers and ip addresses outside the tcp/ip headers then it probably won't work.
Definitely not Supported:
ping (ICMP), FTP in active mode

Source code is available on request. If you are interested in adding support for more protocols let me know as I have provided a simple API to allow support for protocols that require additional translation.