[root@ns1 etc]# vi /etc/squid/squid.conf # http_port 3128 transparent #http_port 3128 # [root@ns1 etc]# vi sysctl.conf # # Controls IP packet forwarding net.ipv4.ip_forward =1 # [root@ns1 etc]# cd sysconfig [root@ns1 sysconfig]# del -r iptables iptables really remove them? [yiN] y ok, removed.... [root@ns1 sysconfig]# cd network-scripts [root@ns1 network-scripts]# vi ifcfg-eth0 DEVICE=eth0 BOOTPROTO=static BROADCAST=192.168.0.255 IPADDR=192.168.0.2 NETMASK=255.255.255.0 NETWORK=192.168.0.0 ONBOOT=yes Esc :q! [root@ns1 network-scripts]# vi ifcfg-eth1 DEVICE=eth1 BOOTPROTO=static BROADCAST=192.168.1.255 IPADDR=192.168.1.2 NETMASK=255.255.255.0 NETWORK=192.168.1.0 ONBOOT=no Esc :wq [root@ns1 network-scripts]# cd .. [root@ns1 sysconfig]# service iptables stop Resetting built-in chains to the default ACCEPT policy: [ OK ] [root@ns1 sysconfig]# iptables -F [root@ns1 sysconfig]# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128 [root@ns1 sysconfig]# service iptables save Saving current rules to /etc/sysconfig/iptables: [ OK ] [root@ns1 sysconfig]# service iptables start Flushing all current rules and user defined chains: [ OK ] Clearing all current rules and user defined chains: [ OK ] Applying iptables firewall rules: [ OK ] [ OK ] [root@ns1 sysconfig]# service iptables status # Table: nat Chain PREROUTING (policy ACCEPT) target prot opt source destination REDIRECT tcp -- anywhere anywhere tcp dpt:http redir ports 3128 # [root@ns1 sysconfig]# service named restart Shutting down named: [ OK ] Starting named: [ OK ] [root@ns1 sysconfig]# service network restart Shutting down interface eth0: [ OK ] Shutting down interface eth1: [ OK ] Shutting down loopback interface: [ OK ] Disabling IPv4 packet forwarding: [ OK ] Setting network parameters: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: [ OK ] [root@ns1 sysconfig]# service squid restart Stopping squid: ................ [ OK ] Starting squid: . [ OK ] [root@ns1 sysconfig]# vi iptables # # Generated by iptables-save v1.2.10 on Wed Mar 11 23:53:30 2015 *mangle :PREROUTING ACCEPT [293:35628] :INPUT ACCEPT [92609:35464443] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [253:37390] :POSTROUTING ACCEPT [91317:42206492] COMMIT # Completed on Wed Mar 11 23:53:30 2015 # Generated by iptables-save v1.2.10 on Wed Mar 11 23:53:30 2015 *nat :PREROUTING ACCEPT [4:212] :POSTROUTING ACCEPT [4:255] :OUTPUT ACCEPT [4:255] [0:0] -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128 COMMIT # Completed on Wed Mar 11 23:53:30 2015 # Generated by iptables-save v1.2.10 on Wed Mar 11 23:53:30 2015 *filter :INPUT ACCEPT [294:35808] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [255:37614] COMMIT # Completed on Wed Mar 11 23:53:30 2015 Esc :q! [root@ns1 sysconfig]#