Saturday, May 16, 2009

SQUID - Allowing internet traffic to go through a different gateway

Tested - CentOS 5- Custom iptables 1.4.1

1)iptables -t mangle -I OUTPUT -m owner --uid-owner squid -j MARK --set-mark 0x1

2)iptables-save > /etc/sysconfig/iptables

3)edit /etc/iproute2/rt_tables and add a line:
101 squid

4)/etc/sysconfig/network-scripts/rule-eth0:
fwmark 0x1 table 101 pref 1000

/etc/sysconfig/network-scripts/route-eth0:
default via 10.0.0.2 dev eth0 table 101

*You can do this manually:
/sbin/ip rule add fwmark 0x1 table 101 pref 101
/sbin/ip route add default via 10.0.0.2 dev eth0 table 101



5)Restart network service

service network restart

6)Check that the ip rules

ip route list table 101
ip rule show

No comments:

Post a Comment

Followers