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

What Is it?

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.

What it is not

NAT is NOT a proxy server. Don't configure your web browser or anything else to use a proxy. NAT operates completely transparently. Nor is it a high performance solution. If you really need the speed, you should something like Linux instead as Be's networking is currently leaves much to be desired.

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 (not in your home directory) NOTE: NAT automatically turns on IP forwarding and requires this feature to operate, so be sure to leave it checked in the Network preferences.

Setting up your LAN

After configuring your machine you will now need to set up the machines on your LAN to use it as the default gateway. Consult the appropriate documentation for those systems on how to do this. You will also need to assign IP addresses from the "unroutable" blocks assigned for this purpose. The class C blocks are 192.168.0.x - 192.168.255.x. Your NAT machine should also use one of these addresses (that will be your gateway IP)

Advanced Settings

There are additional configuration options that you can tweak if you want. Defaults that NAT uses are shown parentheses.

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 (4) 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.

Static Port Mapping

Static Port Mapping allows you map certain ports on your NAT machine to ports on other machines on your LAN. This allows you to run things like web servers, etc, from other machines through your NAT box.

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 or initiates a separate connection from the server back to the client 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.

Version history

1.5.1
Fixed bug where the config app wouldn't add its settings if there wasn't already a nat section in the network file.

1.5
GUI interface
Static Port Mapping
Fixed bug where only UDP sockets were being created.
Now looks for FIN flag in TCP packets so we can reclaim the port immediately when a connection closes.
Now waits for threads to die in destructor. This should make net restarts a bit more stable.

1.0 Initial release

And a big thanks to Olaf Seibert for his very thorough testing and great suggestions.