Question

Squid As a Default Gateway

Asked by: cchinoy

I have recently set up Squid 2.5 Stable 6 running on FreeBSD box running 4.9

Everything is working, however I have all my client machines using an automatic configuration script, so that everyone has to pass through the Squid box to get to the Internet.

Since it is possible to connect using alternate browsers, is there a way to make the squid box a Default gateway, rather than my firewall? This way nobody will be able to bypass the proxy.

Currently my firewall is responsible for NAT and PAT... The firewall is a Cisco Pix 506.

Thanks in advance

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-09-01 at 08:27:13ID21115389
Tags

squid

,

gateway

,

freebsd

Topic

FreeBSD

Participating Experts
3
Points
500
Comments
25

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. FreeBSD NAT linitations
    Does anyone know the viable limitations on the number of computers that you can have behind a FreeBSD firewall running NAT? How does perfomance drop off as the number of computers is increased. Also, what are the most important factors in the performance hits?
  2. PIX 525 NAT & PAT problems?
    My proxy server is connected to the inside interface on the PIX 525. PIX is set to allow only port 80 and port 443 traffic out from the proxy server. All internal users were set to use the proxy from IE for Internet browsing. This worked well until I I had to set up a se...
  3. Global NAT pool not PAT
    I have a pix that has VPN connections originating on the inside trying to go out... as in some users have to connect to outside VPNs. my question is, the customer has 12 public IPs given to them from providder. T1 > 2600 > Pix > Switch > workstations in that co...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ramazanyichPosted on 2004-09-01 at 08:37:19ID: 11953854

 

by: cchinoyPosted on 2004-09-02 at 12:09:17ID: 11967034

This is the procedure necessary if there is a Cisco Router. I don't have a Cisco Router. I have a Cisco Pix 506 Firewall. The Firewall can not route any packets.

Currently the Firewall is setup to forward everything to the router of my ISP. The router is not under my control...

So essentially I need to understand how incoming requests to squid on Port 80 can be forwarded to squid port 3128 ?

Thanks,

 

by: ramazanyichPosted on 2004-09-02 at 12:51:25ID: 11967520

just add another host_port directive:
http_port 80

see details on
http://squid.visolve.com/squid/squid24s1/network.htm#http_port

 

by: cchinoyPosted on 2004-09-02 at 12:55:39ID: 11967558

This will involve running squid as Root, since low level ports can only be run as root.

I have configured squid to run on a separate group and user for security reasons.

 

by: ramazanyichPosted on 2004-09-02 at 13:04:11ID: 11967660

In that case use use
cache_effective_user username
cache_effective_group groupname

and start squid as root. It will start listenign on port 80 and change user on which squid will run. See details
http://squid.visolve.com/squid/squid24s1/admin_parameter.htm#cache_effective_user

 

by: cchinoyPosted on 2004-09-02 at 13:10:04ID: 11967717

According to my squid documentation , it is not advisable to run squid as root because of potential security concerns - I am looking for a work-around to get transparent proxy working without running it as root.

 

by: ramazanyichPosted on 2004-09-02 at 13:22:42ID: 11967875

It will not run as root. It will change PID to your squid user.
Start it and see the owner of squid processes using ps.

 

by: cchinoyPosted on 2004-09-02 at 13:46:44ID: 11968124

Ok... Here is my configuration:

cache_effective_user squid
cache_effective_group squid

Squid being the group and userid I created to run squid...

What did you want me to change this to

cache_effective_user root
cache_effective_group wheel    ????

Please clarify and I will give it a try....

 

by: ramazanyichPosted on 2004-09-02 at 13:52:11ID: 11968177

it should run with your cache_efective_user and cache_effective_group.
Just add
http_port 80
and try to start squid as user root.
It should now listen on port 80 and 3128 and squid processes will run as squid user.

 

by: jdw_2004Posted on 2004-09-17 at 21:31:08ID: 12090403

You may want to take a look at ipnat portion of the IPFilter code.  

YourPrompt> man 8 ipnat
YourPrompt> man 5 ipnat

You'll have to build a kernel using a config with this line:

options IPFILTER

Then, you'd route your client PCs to the squid box, enable routing on the squid box (gateway_enable="YES" in /etc/rc.conf).

Reboot and set up an ipnat.conf file with an entry similar to the following:

rdr xx0 0.0.0.0/0 port 80 -> 127.0.0.1 port 3128

Then "ipnat -f ipnat.conf"

Oh, you also need to build squid with the option "--enable-ipf-transparent" for this to work.  Otherwise it may not be able to figure out what site your clients wanted.

This should give you the transparent redirection you're looking for.




 

by: jdw_2004Posted on 2004-09-17 at 21:32:32ID: 12090406

Oh, and you should not need to run squid on port 80 or give it special permissions for the above to work for you.  ipnat handles all of that as a kernel module.

 

by: cchinoyPosted on 2004-09-20 at 08:16:38ID: 12102892

Finally,

This is exactly what I am looking for. It is very clear and consise.

I am a newbie to FreeBSD, but I am doing well so far (I think). I understand your email but I have a few followup questions. Please forgive my ignorance

1. I have never rebuild the kernel before. I take it that all I need to do is add the line  - options IPFILTER - to the kernel and recompile? Would you happen to have a document or a site that would detail exactly what needs to be done?

2. I take it that in the command

rdr xx0 0.0.0.0/0 port 80 -> 127.0.0.1 port 3128

xx refers to my NIC. How can I find out what the name of my NIC is on my system?

3. I believe I did NOT create squid with --enable-ipf-transparent. so do I have to

./configure --enable-ipf-transparent
make
make all

All over again?

4. Is there anything that I would have to create i.e. an *.sh file so that certain daemons fire up automatically when the server is rebooted? I have created one for squid so that is launches automatically when the server is rebooted. I was wondering if this needs to be done for ipnat?

All over again?

 

by: jdw_2004Posted on 2004-09-20 at 08:49:20ID: 12103215

1)

The definitive resource for kernel building is the FreeBSD handbook:

http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-building.html

2) ifconfig will tell you what your network interface(s) is (are).  If you have two, you want the rdr on the *inbound* interface (the one that faces the clients).

3) Yes, that's exactly correct.  Don't forget make install.

4) ipnat is a kernel module and so will load itself once compiled in.

Good luck!

 

by: cchinoyPosted on 2004-09-20 at 13:05:16ID: 12106050

Ok,

I was able to compile and install the new kernel with the

options IPFILTER

option. However, I do not see any file called ipnat.conf in the /etc directory. Do I have to create this myself? Am I missing anything?

Thanks,

 

by: jdw_2004Posted on 2004-09-20 at 13:56:40ID: 12106548

You will indeed have to create the /etc/ipnat.rules file yourself.  (Ours is called ipnat.conf but I see that FreeBSD has standardized on ipnat.rules.)  

You wiil also need to add the following in /etc/rc.conf:

ipnat_enable="YES"

This will cause it to load the rule(s) on startup.  Sorry for the confusion.

 

by: cchinoyPosted on 2004-09-20 at 14:26:26ID: 12106777

I guess if you were to call it something other than ipnat.rules, you would have to add a separate line to the /etc/rc.conf like

ipnat_rules=/etc/ipnat.conf

Either way, I added

ipnat_enable="YES" (I am curious. Does this mean that my FreeBSD box is doing NAT? My Cisco box currently does NAT and PAT for my network)

add I created the /etc/ipnat.rules with the following

rdr xxx 0/0 port 80 -> 127.0.0.1 port 3128 tcp

add life was good. Transparent proxy is working !!!! Thanks for all you help and pointing me in the right direction. I will add that up top of this you must make sure that the following exists within your squid.conf file for transparent proxy to work. (For anybody else who happens upon this post and is trying to set this up as well):

        http_port 8080
        httpd_accel_host virtual
        httpd_accel_port 80
        httpd_accel_with_proxy on
        httpd_accel_uses_host_header on

 

by: jdw_2004Posted on 2004-09-20 at 14:48:14ID: 12106954

Your FreeBSD box is using its NAT functionality to do the transparent redirection (those things happen at the same spot in the network stack and so are handled by the same code).  Setting up an actual NAT would use the "map" ipnat ruletype instead of "rdr."

It is a sort of NAT if you think about it.  Usually with NAT you have a client , the NAT, and a server.  The NAT pretends to be the client while talking to the server.  In this case, the NAT pretends to be the server while talking to the client.  So it's really the same thing, just from a different perspective.

I don't think you need those squid.conf lines you quoted.  Those are for reverse proxy (accel) configuration, which is something entirely different, and you are not running on port 8080.

In any case, I'm glad it's working for you.





 

by: cchinoyPosted on 2004-09-22 at 06:54:41ID: 12122946

I got this information right off the Squid website (See below)... I actually remed (#) those items to see if it made a difference and it did. The minute I disabled those tags, transparent proxy no longer worked. Either way, I appreciate all you help in getting this to work.

However, I have one problem now that I didn't have before. I created an acl to block all ports except 80 and 21. This worked prior to the setup of transparent proxy but now it no longer works.

acl !Safe_ports port 1-20
acl !Safe_ports port 22-79
acl !Safe_ports port 81-65535

http_access deny !Safe_ports

I have tried them in different areas in the squid.conf file but with no luck.. Is there something I am missing?


The http_port 8080 in this example assumes you will redirect incoming port 80 packets to port 8080 on your cache machine. If you are running Squid on port 3128 (for example) you can leave it there via http_port 3128, and redirect to that port via your IP filtering or forwarding commands.

In the httpd_accel_host option, virtual is the magic word!

The httpd_accel_with_proxy on is required to enable interception proxy mode; essentially in interception proxy mode Squid thinks it is acting both as an accelerator (hence accepting packets for other IPs on port 80) and a caching proxy (hence serving files out of cache.)

You must use httpd_accel_uses_host_header on to get the cache to work properly in interception mode. This enables the cache to index its stored objects under the true hostname, as is done in a normal proxy, rather than under the IP address. This is especially important if you want to use a parent cache hierarchy, or to share cache data between interception proxy users and non-interception proxy users, which you can do with Squid in this configuration.

 

by: jdw_2004Posted on 2004-09-22 at 08:22:45ID: 12123889

acl !Safe_ports port 1-20

is invalid syntax.

acl Safe_ports port 1-20
[etc]

is correct

Then,

http_access deny !Safe_ports

means "deny if Safe_ports is not matched."

 

by: cchinoyPosted on 2004-09-22 at 09:52:30ID: 12125071

Well here is the problem...

If I have my squid box as the default gateway then my rules to block these ports i.e 443 no longer work. However, if I put in the proxy setting in the web browser the ports are no blocked.

Since ports other than 80 are not capable of transparent proxy, I guess the ideal situation would be to setup the squid box as your default gateway, but at the same time configure the browser to the squid box as well. Is this the case? or am I totally off?

 

by: jdw_2004Posted on 2004-09-22 at 10:33:22ID: 12125492

If you use the correct syntax for your ACL definition, it will probably work better.

 

by: cchinoyPosted on 2004-09-22 at 10:40:52ID: 12125587

Tried it that way and various other ways. It will only work if the proxy settings are explicitly set in Internet Explorer.

 

by: cchinoyPosted on 2004-09-22 at 13:38:36ID: 12127494

I did a little research and what I want to do is not possible since Squid is a HTTP proxy server, and can't be used to proxy other protocols.

However, implementing the transparent proxy combined with a Automatic Configuration script will allow you to make sure that nobody will be able to by-pass your proxy (See below for a sample configuration script). The language is java and you must save with this with a *.pac extension. Modify according to your environment.

function FindProxyForURL(url,host) {
 if (url.substring(0,5) == "http:") {
  return "PROXY xxx.xxx.xx.xx:3128; DIRECT";}
 else if (url.substring(0,6) == "https:") {
  return "PROXY xxx.xxx.xx.xx:3128; DIRECT";}
 else {
  return "DIRECT"; }
}

 

by: dkltPosted on 2004-10-08 at 10:51:09ID: 12261221

Wouldnt it be easiler to use ipchains and Squid together? no need to recompile anything for testing...

I remember my uni used to forward all port 80 access to a transparent cache/proxy and intentionally ban all outgoing traffic to non-80 ports. Problem... some webserver run on port 81, then access to those server will timeout.

cchinoy,
 "I did a little research and what I want to do is not possible since ..."

What exactly u want to do??? I thought u only want to force all out-going port-80 access to firstly fetch from local proxy. You can do that quite easily without configurating any browser...


-Dan

 

by: jdw_2004Posted on 2004-10-09 at 09:27:58ID: 12266722

1) This question is closed.

2) ipchains does not exist on FreeBSD.

3) He is looking to redirect other ports, not just 80.

4) https cannot be transparently redirected as it implements the CONNECT method which requires proxy awareness.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...