Running simultaneously multiple instances of Squid bound to network interfaces in different subnets
save the configuration, which is common to the both instances, into the /etc/squid/main.conf file
save the configuration of the first instance into the /etc/squid/squid1.conf file
visible_hostname proxy1
http_port 192.168.100.254:3128
tcp_outgoing_address 192.168.100.254
udp_outgoing_address 192.168.100.254
pid_filename /var/run/squid/squid1.pid
coredump_dir /var/spool/squid/squid1
access_log /var/log/squid/access_squid1.log
cache_log /var/log/squid/cache_squid1.log
include /etc/squid/main.conf
save the configuration of the second instance into the /etc/squid/squid2.conf file
visible_hostname proxy2
http_port 192.168.200.254:3128
tcp_outgoing_address 192.168.200.254
udp_outgoing_address 192.168.200.254
pid_filename /var/run/squid/squid2.pid
coredump_dir /var/spool/squid/squid2
access_log /var/log/squid/access_squid2.log
cache_log /var/log/squid/cache_squid2.log
include /etc/squid/main.conf
create required folders
mkdir /var/spool/squid/{squid1,squid2}
chown squid:squid /var/spool/squid/*
chmod 750 /var/spool/squid/*
create the /usr/lib/systemd/system/squid1.service unit file for the first instance
[Unit]
Description=Squid caching proxy (squid1)
After=syslog.target network.target nss-lookup.target
[Service]
Type=forking
LimitNOFILE=16384
ExecStart=/usr/sbin/squid -n squid1 -f /etc/squid/squid1.conf
ExecReload=/usr/sbin/squid -n squid1 -k reconfigure -f /etc/squid/squid1.conf
ExecStop=/usr/sbin/squid -n squid1 -k shutdown -f /etc/squid/squid1.conf
TimeoutSec=0
[Install]
WantedBy=multi-user.target
create the /usr/lib/systemd/system/squid2.service unit file for the second instance
[Unit]
Description=Squid caching proxy (squid2)
After=syslog.target network.target nss-lookup.target
[Service]
Type=forking
LimitNOFILE=16384
ExecStart=/usr/sbin/squid -n squid2 -f /etc/squid/squid2.conf
ExecReload=/usr/sbin/squid -n squid2 -k reconfigure -f /etc/squid/squid2.conf
ExecStop=/usr/sbin/squid -n squid2 -k shutdown -f /etc/squid/squid2.conf
TimeoutSec=0
[Install]
WantedBy=multi-user.target
create the /etc/sysconfig/network-scripts/rule-lo file with additional routing rules
priority 10100 from 192.168.100.254 table 100
priority 10200 from 192.168.200.254 table 200
create the /etc/sysconfig/network-scripts/route-lo file with additional routes
default via 192.168.100.1 table 100
default via 192.168.200.1 table 200
reboot the system