Blog

03/06/2019

Squid Proxy Server Change Outgoing IP Address



I have Squid caching proxy server deployed on Rackspace based server in UK. This server has four IP address. I would like to change outgoing IP addresses from default 1.2.3.1 to 1.2.3.4. How do I change proxy server outgoing IP address under Linux or Unix operating systems?


You need to configure the option tcp_outgoing_address in squid.conf file. This option allows you to map requests to different outgoing IP addresses. The IP address can be based on the username or source address of the user making the request. The syntax is:

tcp_outgoing_address YOUR-IP-ADDRESS-HERE

Configuration

Edit the squid.conf file:
# vi /etc/squid/squid.conf
Find or add the following configuration directive:

tcp_outgoing_address 1.2.3.4

Save and close the file. Reload the squid proxy server / config file changes by typing the following command:
# squid -k reconfigure
OR
# service squid reload

Setting up multiple outgoing IP addresses

You can forward clients request based on IPs for certain users:

#define acl
acl admin 192.168.1.100
acl tom 192.168.1.101
acl raj 192.168.1.102
 
# set up outgoing rule
tcp_outgoing_address 192.168.1.254 admin
tcp_outgoing_address 192.168.1.253 tom
tcp_outgoing_address 192.168.1.253 raj

However, forwarding clients with dedicated IPs for certain subnets is more useful:

## full filtering enabled using iptables on 10.0.0.0/24 and routed via squid##
acl throttle_service_net src 10.0.0.0/24
 
## admins are skip from this limits ##
acl admins_service_net src 192.168.1.0/24
 
## Set rules ##
tcp_outgoing_address 10.1.0.2 throttle_service_net
tcp_outgoing_address 192.168.1.254 admins_service_net

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

20/08/2019

Start your Bitcoin Exchange with our Software

Start your Bitcoin Exchange with our Software Setup your white label bitcoin exchange right away. Or create your own cryptocurrency using...
14/08/2019

How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...
14/08/2019

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....