Firstly masquerading can only work with ported protocols – such as TCP or UDP. It specifically will not work with ICMP, so ping and traceroute will not work (unless your ping and/or traceroute have been modified to use a different method of working).
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.
4.2 Incoming services
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.
4.3 Supported Client Software and Other Setup Note
Generally, application that uses TCP and UDP should work. If you have any suggestion about applications that are not compatible with IP Masquerade, please email to me with the name of client and a brief description.
Clients that Work
all supported platforms, surfing the web
POP & SMTP
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
anything based on IRC
all supported platforms, with ip_masq_irc.o modules
all supported platforms
all supported platforms
Real Audio Player
Windows, network streaming audio, with ip_masq_raudio module loaded
True Speech Player 1.1b
Windows, network streaming audio
Internet Wave Player
Windows, network streaming audio
Worlds Chat 0.9a
Windows, Client-Server 3D chat program
Windows, Client-Server 3D chat program
Internet Phone 3.2
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)
NCSA Telnet 2.3.08
DOS, a suite containing telnet, ftp, ping, etc.
PC-anywhere for windows 2.0
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 net-acct package
Linux, network administration-account package
Clients that do not Work
Intel Internet Phone Beta 2
Connects but voice travels one way (out) Traffic only
Intel Streaming Media Viewer Beta 1
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!
Platforms/OS Tested as on OTHER machines
- Windows 95
- Windows NT (both workstation and server)
- Windows For Workgroup 3.11 (with TCP/IP package)
- Windows 3.1 (with Chameleon package)
- Novel 4.01 Server
- OS/2 (including Warp v3)
- Macintosh OS (with MacTCP or Open Transport)
- DOS (with NCSA Telnet package, DOS Trumpet works partially)
- Amiga (with AmiTCP or AS225-stack)
- VAX Stations 3520 and 3100 with UCX (TCP/IP stack for VMS)
- Alpha/AXP with Linux/Redhat
- SCO Openserver (v18.104.22.168 and 5)
- IBM RS/6000 running AIX
- (Anyone tried other platforms?)
4.4 IP Firewall Administration (ipfwadm)
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 22.214.171.124 ipfwadm -I -a reject -V 192.168.255.1 -S 192.168.0.0/16 -D 126.96.36.199/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 188.8.131.52 ipfwadm -O -a reject -V your.static.PPP.address -S your.static.PPP.address/32 -D 184.108.40.206/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 220.127.116.11. ipfwadm -F -a reject -W ppp0 -S 192.168.0.0/16 -D 18.104.22.168/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 22.214.171.124, 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.
4.5 IP Masquerade and Demand-Dial-Up
- If you would like to setup your network to automatically dial up the Internet, the diald demand dial-up package will be of great utility.
- To setup the diald, please check out the Setting Up Diald for Linux Page
- Once diald and IP masq have been setup, you can go to any of the client machines and initiate a web, telnet or ftp session.
- Diald will detect the incoming request, then dial up your ISP and establish the connection.
- There is a timeout that will occur with the first connection. This is inevitable if you are using analog modems. The time taken to establish the modem link and the PPP connections will cause your client program to timeout. This can be avoided if you are using an ISDN connection. All you need to do is to terminate the current process on the client and restart it.
4.6 IPautofw Packet Fowarder
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.