|
Using Shorewall with Squid |
|
There may be a requirement to exclude additional destination hosts or networks from being redirected. For example, you might also want requests destined for 130.252.100.0/24 to not be routed to Squid.
ACTION SOURCE DEST PROTO DEST
PORT(S)SOURCE
PORT(S)ORIGINAL
DESTREDIRECT loc 3128 tcp www -
!206.124.146.177 ACCEPT fw net tcp www
ACTION | SOURCE | DEST | PROTO | DEST PORT(S) |
SOURCE PORT(S) |
ORIGINAL DEST |
REDIRECT | loc | 3128 | tcp | www | - |
!206.124.146.177,130.252.100.0/24 |
To exclude additional hosts or networks, just add additional similar rules.run_iptables -t nat -I loc_dnat -p tcp --dport www -d 130.252.100.0/24 -j RETURN
echo 202 www.out >> /etc/iproute2/rt_tables
if [ -z "`ip rule list | grep www.out`" ] ; then
ip rule add fwmark 202 table www.out
ip route add default via 192.168.1.3 dev eth1 table www.out
ip route flush cache
echo 0 > /proc/sys/net/ipv4/conf/eth1/send_redirects
fi
ZONE |
INTERFACE |
BROADCAST |
OPTIONS |
loc |
eth1 |
detect |
routeback |
ACTION | SOURCE | DEST | PROTO | DEST PORT(S) |
SOURCE PORT(S) |
ORIGINAL DEST |
ACCEPT |
loc | loc |
tcp | www | |
SOURCE |
DESTINATION |
POLICY |
LOG LEVEL |
BURST PARAMETERS |
loc |
loc |
ACCEPT |
iptables -t mangle -A PREROUTING -i eth1 -s ! 192.168.1.3 -p tcp --dport 80 -j MARK --set-mark 202
iptables -t nat -A PREROUTING -i eth0 -d ! 192.168.1.3 -p tcp --dport 80 -j REDIRECT --to-ports 3128
If you are running RedHat on the server, you can simply execute the following commands after you have typed the iptables command above:
iptables-save > /etc/sysconfig/iptables
chkconfig --level 35 iptables on
echo 202 www.out >> /etc/iproute2/rt_tables
if [ -z "`ip rule list | grep www.out`" ] ; then
ip rule add fwmark 202 table www.out
ip route add default via 192.0.2.177 dev eth1 table www.out
ip route flush cache
fi
iptables -t mangle -A PREROUTING -i eth2 -p tcp --dport 80 -j MARK --set-mark 202
B) Set MARK_IN_FORWARD_CHAIN=No in /etc/shorewall/shorewall.conf and add the following entry in /etc/shorewall/tcrules:
C) Run Shorewall 1.3.14 or later and add the following entry in /etc/shorewall/tcrules:
MARK
SOURCE
DESTINATION
PROTOCOL
PORT
CLIENT PORT
202
eth2
0.0.0.0/0
tcp
80
-
MARK
SOURCE
DESTINATION
PROTOCOL
PORT
CLIENT PORT
202:P
eth2
0.0.0.0/0
tcp
80
-
ACTION
SOURCE
DEST
PROTO
DEST
PORT(S)
CLIENT
PORT(2)
ORIGINAL
DEST
ACCEPT
loc
dmz
tcp
80
ACCEPT
dmz
net
tcp
80
iptables -t nat -A PREROUTING -i eth0 -d ! 192.0.2.177 -p tcp --dport 80 -j REDIRECT --to-ports 3128
If you are running RedHat on the server, you can simply execute the following commands after you have typed the iptables command above:
iptables-save > /etc/sysconfig/iptables
chkconfig --level 35 iptables on
ACTION |
SOURCE |
DEST |
PROTO |
DEST PORT(S) |
CLIENT PORT(2) |
ORIGINAL DEST |
ACCEPT |
Z |
SZ |
tcp |
SP |
||
ACCEPT |
SZ |
net |
tcp |
80 |
ACTION |
SOURCE |
DEST |
PROTO |
DEST PORT(S) |
CLIENT PORT(2) |
ORIGINAL DEST |
ACCEPT |
loc |
$FW |
tcp |
8080 |
||
ACCEPT |
$FW |
net |
tcp |
80 |
Updated 1017/2003 - Tom Eastep
Copyright © 2003 Thomas M. Eastep.