Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
The easiest way to do it and not leave any loop holes is to setup a transparent proxy that forces the traffic through the squid proxy. To do this you'll need two nics in the linux box and you'll need to install iptables. You basically set up iptables to redirect all incoming traffic on port 80 to port 3128. Then all of your machines on the lan will use your squid box as their gateway.
It is easiest to have iptables and squid run on the same box, I can't seem to get the setup in section 6 to work. (Got a question posted on that below ) Let me know if you have any more questions about it.
Mark
(Oh yeah, and check out dansguardian for content filtering)
for basic squid proxy setup, install squid, open /etc/squid.conf and edit these lines
1.
visible_hostname <your_machine_name>
http_port 3128
2. delete this line.
http_access deny all
3. In browsers of client machines set proxy ip as the ip of the proxy machine, and set port as 3128
with two nic's set the external interface ip in range with the subnet of external ip.
set the internal interface (nic) ip in range within subnet of internal ip. other things work fine with defaults.
if you are planning with larger netwworks do acquianted with maximum file size in memory, maximum file size in hardisk, min file size in memory etc enttries.
I've installed a second NIC.
eth0 is set to static 10.0.0.1 255.0.0.0 DG 10.0.0.2 (the DSL router's IP) and connected to one of the ports on the DSL router.
eth1 is set to static 10.0.0.10 255.0.0.0 DG 10.0.0.2 and connected to the router of my local LAN (range 10.0.0.0/8)
The contents of my squid file looks like this:
Quote:
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd
#Recommended minimum configuration:
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
acl home_network src 10.0.0.0/8
acl BadSites dstdomain "usr/local/etc/restricted-sites.squid"
acl ncsa_users proxy_auth REQUIRED
My problems were:
1) I've lost internet connectivity from the squid box as well as from all the clients.
2) The squid's network config seemed as if it was losing an IP. When I ifconfiged, it showed as set above. After pinging several ips in my network, ifconfig suddenly reported eth1 as 169.254 ip (apipa address). How and/or why does eth1's static IP get changed to an APIPA address?
3) Is my default gateway correct as being the DSL router (10.0.0.2).
4) Should the proxy settings in my clients browsers be eth1 (internal) or eth0 (dsl router)?
5) Do I need to set iptables and firewall as described in above article? I don't need to use transparant proxy?
6) Where do I change the hostname of my squid box, which is now set to localhost?
7) Will someone also confirm that my squid.conf is correct. I did setup the ncsa_authorisations.
~#ifconfig -a #get known devices
~#route -n #get the route table
The above commands will show you where you are going now. The wrong way!
Looks like the server(proxy) should be connected to the DSL with eth0 and the eth1 should go to the LAN. Make sure to plug eth1 into the router LAN ports not the WAN.
You will need to enable masquerading, you can use this guide.
Under Linux kernel 2.4.x, packet mangling has considerably changed. This includes the masquerading, firewalling, and port forwarding features. This document assumes you're using modules, if you're not, disregard the code in the following script that tests for the loaded module. The following is a self contained script that enables and sets basic masquerading (assuming kernel kernel support already exists) at boot time. You may use this example, or modify existing init scripts to include the code.
You can look at the code snippet to see what you need to adapt.
Once you have the NAT working then you can modify for the proxy. A simple LQ search or GOOGLE will get you loads of howto and setup information. Use it!
Last edited by onebuck; 11-02-2007 at 09:53 AM.
Reason: false enter
Fedix are you planning on configuring the browsers on each of the PC's on the LAN to proxy to your squid box? Or are you going to set the default gateway of all your machines to your squid box and use iptables to redirect traffic to port 3128? Next what does the non dsl-router config look like? I'm assuming this is what is causing eth1 to lose the static ip.
As for setting a new hostname, you can do that any number of ways starting with editing etc/hosts.
You could also try in etc/sysconfig/network and look for
HOSTNAME=
or try the hostname command
hostname [new hostname] (this is only temporary however)
Your squid config looks fine btw, I think this may be a topology configuration issue.
I scanned your configuration, and feel theres some problem. I assume You wrote DG for gateway.
I am speaking in terms of the configuration schema i am using in my 50+ lab, but alternate schemes may work better.
1. Donot put Dg for the internal lan card, eth1 put it blank
2.I think the second nics dg should be set to the ip given by your service provider. If thats the ip given to the router then it will be okay.
3. Forward traffic from external nic to internal nic using masquerading . Put the code in rc.local file, thats easy.
Apart from these configuration changes ,have a look at the squid.conf file. change the http_access deny all line to http_access deny none. change visible_hostname localhost to visible_hostname <my_system_name> where my_system_name is the name of your system.
Fedix are you planning on configuring the browsers on each of the PC's on the LAN to proxy to your squid box? Or are you going to set the default gateway of all your machines to your squid box and use iptables to redirect traffic to port 3128?
Don't know. Which is the best? The default gateway (DG) of my machines is currently set to the DSL router (10.0.0.2 of above config). This is the one part I still don't get right.
------------------- reachjohney :
Quote:
2.I think the second nics dg should be set to the ip given by your service provider.
My DSL router gets a dynamic IP when authenticating to my internet service provider. But the lan side of the DSL router is set to 10.0.0.2. Can 10.0.0.2 then be the DG? It worked that way before squid.
I've read the masquearading document (http://linux.ardynet.com/ipmasq/ipmasq.php3) but don't know which to use?
1) Must I first download and install masquerade, or is it part of the kernell?
2) Do I use "Simple IPTABLES masquerade commands" sample, or other samples?
3) I also do want to implement a firewall for security. Is the firewall of masquerading (Ipfwadm) sufficient?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.