I'm using a PC running on CentOS 6.7 with 2 NIC's (eth0 & eth1) as a Squid Proxy server. eth0 (Red interface/ 192.168.0.2/24) is connected physically with the router (192.168.0.1/24) while the eth1 (green interface/ 192.168.1.1/24) is connected with the LAN.
eth0:
Connect automatically
Method = Manual
Address = 192.168.0.2
Mask = /24
GW = 192.168.0.1
DNS = 8.8.8.8, 8.8.4.4
eth1:
Connect automatically
Method = Manual
Address = 192.168.1.1
Mask = /24
GW = 192.168.0.2
DNS = 8.8.8.8, 8.8.4.4
While configuring the CentOS box as the proxy server I did following configurations:
Updated yum and installed Squid
edited /etc/squid/squid.conf file as shown bellow:
#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
#acl localnet src 172.16.0.0/12 # RFC1918 possible internal networkacl localnet src 192.168.1.0/24 # RFC1918 possible internal network
#acl localnet src fc00::/7 # RFC 4193 local private network range
#acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
.
.
.(other lines kept same for now)Started the Squid proxy:
# service squid start # chkconfig squid on
Edited /etc/sysctl.conf file as follows
net.ipv4.ip_forward=1
Edited the /etc/sysconfig/iptables-config file
Changed "no" to "yes" in following to lines: And Saved
IPTABLES_SAVE_ON_STOP="yes" IPTABLES_SAVE_ON_RESTART="yes"
Changed the rules in iptables as follow:
# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# iptables -t filter -D INPUT -j REJECT --reject-with icmp-host-prohibited
# iptables -t filter -D FORWARD -j REJECT --reject-with icmp-host-prohibited
# iptables -t filter -A INPUT -p tcp --dport 3128 -j ACCEPT
# iptables -A INPUT -j REJECT --reject-with icmp-host-prohibited
# iptables -A FORWARD -i eth1 -p tcp --dport 443 -d www.facebook.com -j DROP
# iptables -A FORWARD -i eth1 -p tcp --dport 443 -d www.youtube.com -j DROP# service iptables save
# chkconfig iptables on
# service iptables restartInstalled the dhcp server (yum install dhcp)
Disabled the Selinux:
# setenforce 0
# vim /etc/sysconfig/selinux and chandge;
SELINUX=enforcing to
SELINUX=disabledEdited the /etc/sysconfig/dhcpd file and add;
DHCPDARGS=eth1
Edited the /etc/dhcp/dhcpd.conf file as bellow:
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.50 192.168.1.220;
option domain-name-servers 8.8.8.8, 8.8.4.4;
# option domain-name "centos.local"
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 600;
max-lease-time 7200;
}Started the dhcp server
# service dhcpd start
# chkconfig dhcpd onFollowing adding filtering sites/rules/file extenstions to,
a.) /etc/squid/acls.txt
b.) /etc/squid/adult.txt and
c.) /etc/squid/badsites.txt files I changed the /etc/squid/squid.conf file:.
.(Above rules as chnaged in step 2)
.
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
visible_hostname cetos-server.local
acl social dstdomain -i "/etc/squid/acls.txt"
acl badsites dstdomain -i "/etc/squid/badsites.txt"
acl adult url_regex -i "/etc/squid/adult.txt"
acl non-working time SMTWHFS 18:00-23:59
acl non-working time SMTWHFS 00:00-06:00http_access deny non-working
http_access deny social
http_reply_access deny badsites
http_reply_access deny adult# We recomend you to use at least the following line.
hierarchy_stoplist cgi-bin ?# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 10240 16 256
.
.(Other rules were not changed)Restarted squid, dhcpd and iptables:
# chkconfig squid on
# service squid restart# chkconfig iptables on
# service iptables restart# chkconfig dhcpd on
# service dhcpd restart
Once this is done proxy works very well. No PC in LAN can access internet without going through the proxy server (192.168.1.1 Port: 3128).
BUT,
The Problem:
Once I restart the CentOS machine, though all the above configurations are still there and the Squid, DHCP and iptables are running properly (as they were running before the restart of the machine), now a PC in my LAN can access the internet without proxy settings are added to that PC.
(Eg: a PC with 192.168.1.155/24 can access internet without adding proxy server IP and Port in the system proxy settings.)
Could you please help me to rectify this issue?
Thank you.