Some protocols will not currently work with masquerading because they either assume things about port numbers, or encode data in their data stream about addresses and ports - these latter protocols need specific proxies built into the masquerading code to make them work.
Masquerading cannot handle incoming services at all. There are a few ways of allowing them, but they are completely separate from masquerading, and are really part of standard firewall practice.
If you do not require high levels of security then you can simply redirect ports. There are various ways of doing this - I use a modified redir program (which I hope will be available from sunsite and mirrors soon). If you wish to have some level of authorisation on incoming connections then you can either use TCP wrappers or Xinetd on top of redir (0.7 or above) to allow only specific IP addresses through, or use some other tools. The TIS Firewall Toolkit is a good place to look for tools and information.
More details can be found at IP Masquerade Resource.
** The following list is not being maintained anymore. Please refer to this page on applications that work thru Linux IP masquerading and IP Masquerade Resource for more detail. **
Generally, application that uses TCP and UDP should work. If you have any suggestion, hints, or questions about applications with IP Masquerade, please visit this page on applications that work thru Linux IP masquerading by Lee Nevo.
General Clients
all supported platforms, surfing the web
all supported platforms, email client
all supported platforms, remote session
all supported platforms, with ip_masq_ftp.o module (not all sites work with certain clients; e.g. some sites cannot be reached using ws_ftp32 but works with netscape)
all supported platforms, file searching client (not all archie clients are supported)
all supported platforms, USENET news client
Windows(possibly all supported platforms), virtual reality surfing
mainly UNIX based platforms, some variations may not work
all platforms, with ICMP patch
all supported platforms, with ip_masq_irc.o modules
all supported platforms
all supported platforms
Multimedia Clients
Windows, network streaming audio, with ip_masq_raudio module loaded
Windows, network streaming audio
Windows, network streaming audio
Windows, Client-Server 3D chat program
Windows, Client-Server 3D chat program
Windows, Peer-to-peer audio communications, people can reach you only if you initiate the call, but people cannot call you
Windows, Peer-to-peer Text audio whiteboard communications, people can reach you only if you initiate the call, but people cannot call you
all supported platforms, with cuseeme modules loaded, please see IP Masquerade Resource for detail
Windows, with vdolive patch
Note: Some clients such as IPhone and Powwow may work even if you're not the one who initiate the call by using ipautofw package (refer to section 4.6)
Other Clients
DOS, a suite containing telnet, ftp, ping, etc.
MS-Windows, Remotely controls a PC over TCP/IP, only work if it is a client but not a host
uses ntp - network time protocol
Linux, network administration-account package
Connects but voice travels one way (out) Traffic only
Cannot connect to server
Cannot connect to opposite side
will not work - requires a kernel proxy to be written.
Cannot work at present (it makes invalid assumptions about addresses).
Untested, but I think it cannot work unless someone builds an X proxy, which is probably an external program to the masquerading code. One way of making this work is to use ssh as the link and use the internal X proxy of that to make things work!
This section provides a more in-depth guide on using ipfwadm.
This is a setup for a firewall/masquerade system behind a PPP link with a static PPP address follows. Trusted interface is 192.168.255.1, PPP interface has been changed to protect the guilty :). I listed each incoming and outgoing interface individually to catch IP spoofing as well as stuffed routing and/or masquerading. Also anything not explicitly allowed is forbidden!
#!/bin/sh # # /etc/rc.d/rc.firewall, define the firewall configuration, invoked from # rc.local. # PATH=/sbin:/bin:/usr/sbin:/usr/bin # testing, wait a bit then clear all firewall rules. # uncomment following lines if you want the firewall to automatically # disable after 10 minutes. # (sleep 600; \ # ipfwadm -I -f; \ # ipfwadm -I -p accept; \ # ipfwadm -O -f; \ # ipfwadm -O -p accept; \ # ipfwadm -F -f; \ # ipfwadm -F -p accept; \ # ) & # Incoming, flush and set default policy of deny. Actually the default policy # is irrelevant because there is a catch all rule with deny and log. ipfwadm -I -f ipfwadm -I -p deny # local interface, local machines, going anywhere is valid ipfwadm -I -a accept -V 192.168.255.1 -S 192.168.0.0/16 -D 0.0.0.0/0 # remote interface, claiming to be local machines, IP spoofing, get lost ipfwadm -I -a deny -V your.static.PPP.address -S 192.168.0.0/16 -D 0.0.0.0/0 -o # remote interface, any source, going to permanent PPP address is valid ipfwadm -I -a accept -V your.static.PPP.address -S 0.0.0.0/0 -D your.static.PPP.address/32 # loopback interface is valid. ipfwadm -I -a accept -V 127.0.0.1 -S 0.0.0.0/0 -D 0.0.0.0/0 # catch all rule, all other incoming is denied and logged. pity there is no # log option on the policy but this does the job instead. ipfwadm -I -a deny -S 0.0.0.0/0 -D 0.0.0.0/0 -o # Outgoing, flush and set default policy of deny. Actually the default policy # is irrelevant because there is a catch all rule with deny and log. ipfwadm -O -f ipfwadm -O -p deny # local interface, any source going to local net is valid ipfwadm -O -a accept -V 192.168.255.1 -S 0.0.0.0/0 -D 192.168.0.0/16 # outgoing to local net on remote interface, stuffed routing, deny ipfwadm -O -a deny -V your.static.PPP.address -S 0.0.0.0/0 -D 192.168.0.0/16 -o # outgoing from local net on remote interface, stuffed masquerading, deny ipfwadm -O -a deny -V your.static.PPP.address -S 192.168.0.0/16 -D 0.0.0.0/0 -o # outgoing from local net on remote interface, stuffed masquerading, deny ipfwadm -O -a deny -V your.static.PPP.address -S 0.0.0.0/0 -D 192.168.0.0/16 -o # anything else outgoing on remote interface is valid ipfwadm -O -a accept -V your.static.PPP.address -S your.static.PPP.address/32 -D 0.0.0.0/0 # loopback interface is valid. ipfwadm -O -a accept -V 127.0.0.1 -S 0.0.0.0/0 -D 0.0.0.0/0 # catch all rule, all other outgoing is denied and logged. pity there is no # log option on the policy but this does the job instead. ipfwadm -O -a deny -S 0.0.0.0/0 -D 0.0.0.0/0 -o # Forwarding, flush and set default policy of deny. Actually the default policy # is irrelevant because there is a catch all rule with deny and log. ipfwadm -F -f ipfwadm -F -p deny # Masquerade from local net on local interface to anywhere. ipfwadm -F -a masquerade -W ppp0 -S 192.168.0.0/16 -D 0.0.0.0/0 # catch all rule, all other forwarding is denied and logged. pity there is no # log option on the policy but this does the job instead. ipfwadm -F -a deny -S 0.0.0.0/0 -D 0.0.0.0/0 -o
You can block traffic to a particular site using the -I, -O or -F. Remember that the set of rules are scanned top to bottom and -a means "append" to the existing set of rules so any restrictions need to come before global rules. For example (and untested) :-
Using -I rules. Probably the fastest but it only stops the local machines, the firewall itself can still access the "forbidden" site. Of course you might want to allow that combination.
... start of -I rules ... # reject and log local interface, local machines going to 204.50.10.13 ipfwadm -I -a reject -V 192.168.255.1 -S 192.168.0.0/16 -D 204.50.10.13/32 -o # local interface, local machines, going anywhere is valid ipfwadm -I -a accept -V 192.168.255.1 -S 192.168.0.0/16 -D 0.0.0.0/0 ... end of -I rules ...
Using -O rules. Slowest because the packets go through masquerading first but this rule even stops the firewall accessing the forbidden site.
... start of -O rules ... # reject and log outgoing to 204.50.10.13 ipfwadm -O -a reject -V your.static.PPP.address -S your.static.PPP.address/32 -D 204.50.10.13/32 -o # anything else outgoing on remote interface is valid ipfwadm -O -a accept -V your.static.PPP.address -S your.static.PPP.address/32 -D 0.0.0.0/0 ... end of -O rules ...
Using -F rules. Probably slower than -I and this still only stops masqueraded machines (i.e. internal), firewall can still get to forbidden site.
... start of -F rules ... # Reject and log from local net on PPP interface to 204.50.10.13. ipfwadm -F -a reject -W ppp0 -S 192.168.0.0/16 -D 204.50.10.13/32 -o # Masquerade from local net on local interface to anywhere. ipfwadm -F -a masquerade -W ppp0 -S 192.168.0.0/16 -D 0.0.0.0/0 ... end of -F rules ...
No need for a special rule to allow 192.168.0.0/16 to go to 204.50.11.0, it is covered by the global rules.
There is more than one way of coding the interfaces in the above rules. For example instead of -V 192.168.255.1 you can code -W eth0, instead of -V your.static.PPP.address you can use -W ppp0. Personal choice and documentation more than anything.
IPautofw is a generic forwarder of TCP and UDP for Linux masquerading. Generally to utilize a package which requires UDP, a specific ip_masq module needs to be loaded; ip_masq_raudio, ip_masq_cuseeme, ... Ipautofw acts in a more generic manner, it will forward any type of traffic including those which the application specific modules will not forward. This may create a security hole if not administered correctly.