Share internet from Linux to windows with squid3 proxy server

  9 years ago

To share internet connection from your linux to windows/linux with squid3 proxy server and dhcp3 server

just follow the steps bellow:

1. First install squid3 and dhcp3-server

sudo apt-get install squid3

sudo apt-get install dhcp3-server (or install isc-dhcp-server from synaptic)

2.Suppose that the LAN connected network card is eth0 and the internet connected one is eth1

3.sudo gedit /etc/network/interfaces

Delete all the text and paste this text in your interfaces file:

#interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

post-up iptables-restore < /etc/iptables.up.rules

auto eth0
iface eth0 inet static

save the file and close

Here is the IP Address of your LAN interface

4.Make a backup of your squid.conf for future reference

sudo cp /etc/squid3/squid.conf /etc/squid3/squid.conf.original

5.Configure squid3

sudo gedit /etc/squid3/squid.conf

Remove all the text and paste this text in your squid.conf file for a minimal configuration:

http_port 3128 transparent
acl LAN src
acl localnet src
http_access allow LAN
http_access allow localnet
cache_dir ufs /var/spool/squid3 20000 16 256

save the file and close

Where is the range of your LAN interface.

5.sudo gedit /etc/sysctl.conf

Uncomment the lines:


uncommenting means removing the # from the beginning of the lines

6.sudo gedit /etc/iptables.up.rules

Paste this text in the file that opens up:


-A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j DNAT --to-destination
-A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128

Save and close this file.

7.sudo gedit /etc/rc.local

Paste this text at the end(before exit 0) of the file that opens up:
iptables -t nat -A POSTROUTING -s –o eth1 -j MASQUERADE

8.sudo gedit /etc/default/dhcp3-server

Type eth0 in between the quotes in this line:

Save and close the file

9.sudo gedit /etc/dhcp3/dhcpd.conf

Delete all the text and paste this text in the file that opens up:


default-lease-time 3600;
max-lease-time 3600;

option subnet-mask;
option broadcast-address;
option routers;
option domain-name-servers,;
option domain-name "";

subnet netmask {
Save and close the file.

10.sudo /etc/init.d/squid3 restart

Now your other computers connected to the LAN with ip range to can connect to internet through proxy.

Change proxy settings on other computers (windows\linux) to your ip address i.e & port 3128

On windows end:

in windows go to the control panel-internet options-connections(tab).click 'Lan settings'. check 'use a proxy server for your lan...' option. below it, put the host ip ( in this case) and the port no. 3128. this is the system proxy for windows.

if you can set proxy seetings for google chrome then do it . it will do the same as above.

firefox may not detect the system proxy. in this case, options- advance- network (tab) -settings, then check maual proxy and put the ip and port. check 'use this proxy for all protocols'

This method is tested on linux mint 14.1 cinnamon and ubuntu 12.04 LTS
I think it will work on every linux mint and ubuntu version

You may want to skip the steps 8 and 9. This may not affect anything.

If you have another ip range, change the above ip informations carefully.

Be careful that the internet connected device used here is eth1. This may not happen all the time.
Change it according to your network devices

You don't have to start the squid3 proxy manually.It will start at every boot automatically.
You just have to connect your network devices correctly.

At first there may be a problem browsing through the LAN and you and other users may not see the computer lists in the LAN interfaces. Don't be will be fixed in 24 hours.

your computer which has the internet connection may show the LAN interface unmanaged.It's not a problem at all. Whatever happens to the LAN , if connected properly, there will be no problem browsing the internet.

Good Luck.......


jahid_0903014 9 years ago

as per CdnLinuxUser's comment i added "On windows end:" section.