Adding Iptables Rules On SmoothWall
Adding Iptables Rules On SmoothWall
[These modifications only apply to Smoothwall Express 2.0, as GPL 1.0 uses ipchains.]
This page describes how to add additional firewall rules to the Smoothwall Express 2.0
firewall script.
For information on making similar changes to a Smoothwall GPL 1.0 box (using ipchains),
refer to Hilton's Smoothwall GPL 1.0 web site.
Requirements:
You'll need:
Note that you can use various aliases in the firewall script to reference the red and green
network interfaces (ie, $RED_DEV, $GREEN_DEV), ip addresses (ie, $GREEN_ADDRESS), network
addresses (ie, $GREEN_NETADDRESS), and subnets (ie, $GREEN_NETMASK).
These aliases are defined in /var/smoothwall/ethernet/settings and this file should not
be edited, as it's generated by Smoothwall's setup program.
Note that if your red interface is a modem, ISDN, or using PPPoE or PPPoA, you can't use the
$RED_DEV alias, but need to specify the actual interface name, for example, ppp0.
As with any modifications to your Smoothwall, make a backup copy of this file before making
any changes to it, so you can easily revert back to a known working version.
After making changes to the firewall script, you can either reboot your Smoothwall, or run
the following from a command line:
/etc/rc.d/rc.netaddress.down; /etc/rc.d/rc.netaddress.up
This will re-apply the firewall (as well as restart Snort, any VPNs, etc), and your
modifications to the firewall script should be taking effect.
Setting up firewall
then you've probably made a typo or other mistake in the firewall script, and you'll have to
make the appropriate corrections.
Note that you need execute this as a single line if you're accessing your Smoothwall via SSH
- otherwise your SSH connection will be terminated, and you won't be able to re-establish it
without logging onto Smoothwall's console to run the up script!
Also note that if you are using Smoothwall's web proxy in transparent mode, and use the
rc.netaddress.down/up scripts to restart the firewall without rebooting, the appropriate
iptables rules to redirect web traffic through the proxy will not be loaded.
Operation of your transparent proxy can be restored by running the following from a
command prompt:
/usr/local/bin/restartsquid
Note that blocking outbound traffic in this way won't have any effect if you have
Smoothwall's web proxy enabled, and the user configures their browser to use the proxy. To
block this traffic too, you'll either need to block incoming traffic from that user on port 800
(the web proxy port), or implement an ACL in Squid.
You can also block traffic based on the source MAC address:
Note that blocking outbound traffic in this way won't have any effect if you have
Smoothwall's web proxy enabled, and the user configures their browser to use the proxy. To
block this traffic too, you'll either need to block incoming traffic from that user on port 800
(the web proxy port), or implement an ACL in Squid.
This will allow you to prevent anyone behind your Smoothwall from sending email using any
mail servers which you don't want them to use, as well as blocking any outbound email from
a virus/worm which may have infected one of the PCs on your green network.
and replace w.x.y.z with the IP address of the mail server you want to allow.
If you want to allow outbound SMTP to multiple mail servers, just add multiple rules before
the blocking rule, one for each mail server.
Alternatively, if you have a mail server on your green or orange network, and only want to
allow outbound SMTP from it, and block outbound SMTP from all other PCs on your green
and orange networks, use the following:
This rule will block all outbound SMTP traffic from all PCs behind your Smoothwall, except
192.168.0.2.
Note:
Note that some of the Smoothwall fixes may overwrite rc.firewall.up with a newer
version, so if you install a new fix, it may overwrite your changes, so always keep a backup
copy of your rc.firewall.up before patching your Smoothie, so you can reapply the
changes to the new rc.firewall.up.
Similarly, when doing a fresh installation of Smoothwall, only make these changes once
you've fully patched the installation.