![]() |
|
|||||||
|
IntroductionSo, you've got several computers on your home or business network, and you'd like to be able to access the Internet from all of them, probably via a cable (or DSL) modem. Basically you have three options:
The last option is very popular, and is better than nothing, but you can't beat having your own dedicated firewall machine. The first method, as well as being insecure, lacks a certain je ne sais quoi, so I'll show you how to set up NAT using Darren Reed's IP Filter. If you want to use the first or last methods, you're on your own! HardwareIn my experiments, I could only get NAT to work reliably when I had two physical interfaces (i.e., using two virtual interfaces, say hme0 and hme0:1, didn't work). I used hme1 to connect directly to my cable modem, and hme0 as the connection to the rest of my network via a 100 baseT switch. hme1 is under DHCP control per these instructions, and hme0 was set up the conventional way, with the hostname in /etc/hostname.hme0, and the corresponding IP address in /etc/hosts. Installing IP FilterBy far the best way to get IP Filter is install Solaris 10, which comes with Solaris IP Filter (which is based on IP Filter). For previous versions of Solaris, the best way to get IP Filter is to compile a copy of the latest source code, which can be downloaded from the IP Filter home page. As an alternative, I have a compiled version of the package here. This is IP Filter version 3.3.11, compiled on a Sun SPARCstation 20, running Solaris 2.6. I've also used it on a SPARCstation 2 running Solaris 7, but it is provided here without any support (I currently use the Solaris 10 version of IP Filter on a Sun Netra T1 105). You should probably download a more recent binary from Marauding Pirates. Configuring IP Filter on Solaris 10
Once you've successfully installed IP Filter,
you need to configure it. First of all, you
need to make sure that your NAT box will forward
IP packets (it's possible this ability was disabled
for security reasons). As root, run this command:
When you're happy that IP forwarding is enabled, you need to set
up your NAT rules. The file /etc/ipf/ipnat.conf
contains the rules you want to use.
This is the ipnat.conf
file I use, bearing in mind that all of my machines have
an IP address in the 192.168.0.1 to 192.168.0.254 range;
you should change the addresses between "hme1" and the "->"
to suit your needs (note also that I've specified hme1;
put the name of your outbound interface here instead): The 0/32 stuff is some magic to tell IP Filter to use the address currently assigned to the interface - very useful in DHCP client environments! The order of the rules is important; don't change them unless you know what you're doing, otherwise things will break! The first rule allows FTP access from all of your hosts. The second maps the source port numbers to a high range (10000 to 40000 by default), and the third rule maps all other TCP traffic.
Once you've set up your NAT rules, you need to enable packet
filtering for the interface type you're using. This is
done by uncommenting the appropriate line(s) in /etc/ipf/pfil.ap:
When you're happy with your configuration, start the
IP filter services: Assuming all is well, your firewall should now correctly handle NAT, even after a reboot. Assuming this is the case, enjoy! If this page has been useful to you, please consider buying a copy of my book, Solaris Systems Programming. Configuring IP Filter for Previous Versions of SolarisIf you're using a version of Solaris prior to Solaris 10, and assuming you have Solaris 10-capable hardware, I don't know why you wouldn't use Solaris 10, here is the older version of these instructions. But really, you should upgrade to Solaris 10!
First of all, you need to make sure that your NAT box will forward
IP packets (it's possible this ability was disabled
for security reasons). As root, run this command: One caveat applies, though: if you're using NAT and DHCP on the same server (like I do), IP forwarding will not get enabled. So, I install this script as /etc/init.d/ip_forwarding, with a symbolic link to it from /etc/rc2.d/S69ip_forwarding. With this script in place, IP forwarding will be enabled even if you are using a DHCP client.
When you're happy that IP Filter is running, and
IP forwarding is enabled, you need to set up your
NAT rules. The file /etc/opt/ipf/ipnat.conf
contains the rules you want to use.
This is the ipnat.conf
file I use, bearing in mind that all of my machines have
an IP address in the 192.168.0.1 to 192.168.0.254 range;
you should change the addresses between "hme1" and the "->"
to suit your needs (note also that I've specified hme1;
put the name of your outbound interface here instead): The 0/32 stuff is some magic to tell IP Filter to use the address currently assigned to the interface - very useful in DHCP client environments! The order of the rules is important; don't change them unless you know what you're doing, otherwise things will break! The first rule allows FTP access from all of your hosts. The second maps the source port numbers to a high range (10000 to 40000 by default), and the third rule maps all other TCP traffic. Use /etc/init.d/ipfboot stop and /etc/init.d/ipfboot start to test your configuration, and when you're happy that all is working well, reboot. This will make sure that everything still works as expected, even after a reboot. That's about it - enjoy! If this page has been useful to you, please consider buying a copy of my book, Solaris Systems Programming. |
Send any questions or comments to: rich.teer@rite-group.com
Copyright © 1997-2006 by Rich Teer