LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-13-2009, 03:13 AM   #1
sholah
Member
 
Registered: Dec 2006
Posts: 34

Rep: Reputation: 15
Linux bridge + netfilter


Hi all,

I have successfully configured a linux bridge that can filter IP traffic to the internal webserver.

The iptables rule looks like this:

iptables - nat -A PREROUTING -p tcp --dport 80:443 -s 192.168.1.1 -j REDIRECT

What this does is to redirect users based on their IP to the INDEX page of the internal web server of the linux box and it is working perfectly.

So my question is: Does anyone know the iptables rule that will permit the redirection of IP traffic to other web pages on the web server (apart from the index page) of the linux box. If yes, kindly assist me with it.

Thanks
 
Old 01-13-2009, 03:38 AM   #2
ledow
Member
 
Registered: Apr 2005
Location: UK
Distribution: Slackware 13.0
Posts: 241

Rep: Reputation: 34
Quote:
Originally Posted by sholah View Post
Does anyone know the iptables rule that will permit the redirection of IP traffic to other web pages on the web server (apart from the index page) of the linux box. If yes, kindly assist me with it.
That sounds like nonsense to me. You can't redirect *IP* traffic (which is what *ip*tables does) to a *web page*. You can redirect requests to another IP, maybe even another port, but not to a particular webpage.

What you want is a real HTTP proxy that is capable of substituting HTTP content... I would suggest squid but it's not easy to set up if you're not sure of what you're doing. If you don't want to specify a proxy setting on the client machines, you'll probably want to look at transparent proxying, which would fit nicely into your redirect rules - you literally redirect ALL HTTP traffic to the IP of your filtering machine, where squid runs and can play about with the individual URL's or HTTP headers if it wants.

I use this setup all the time - I use bridge + netfilter to put in a firewall machine, then a redirect rule to throw all HTTP from un-managed machines to a special holding page hosted by Apache on the same machine. Additionally, all HTTP traffic from managed machines is redirected through a transparent squid proxy which can do fancy stuff like rewriting the URL's, changing the content etc.
 
Old 01-13-2009, 04:14 AM   #3
sholah
Member
 
Registered: Dec 2006
Posts: 34

Original Poster
Rep: Reputation: 15
ledow,

I guess u missed the part that says my setup is working perfectly. If u know u dont have the answer to my question, u should have kept ur opinion to ur self.
 
Old 01-14-2009, 03:29 AM   #4
ledow
Member
 
Registered: Apr 2005
Location: UK
Distribution: Slackware 13.0
Posts: 241

Rep: Reputation: 34
Quote:
Originally Posted by sholah View Post
ledow,

I guess u missed the part that says my setup is working perfectly. If u know u dont have the answer to my question, u should have kept ur opinion to ur self.
Ignoring the absolute arrogance, no I didn't miss this. Your bridge is working properly, but you asked a question:

Quote:
Originally Posted by sholah View Post
Does anyone know the iptables rule that will permit the redirection of IP traffic to other web pages on the web server (apart from the index page) of the linux box.
which the ENTIRETY of my post refers to. You can redirect IP traffic to any IP/port that you like but you cannot redirect IP traffic to a different *web page*, they are two seperate things. By web page you are implying full URL (e.g. http://localserver/directory/file.html) which you can't do without modifying the HTTP packets themselves (which operate on an entirely seperate layer to the IP packets... thus IP redirection isn't the same thing AT ALL).

I can point FTP packets at port 80 on 1.1.1.1 or POP3 packets at port 0 on 192.168.10.1, it makes no difference to the actual *protocol*. The protocol that you are using here (HTTP) is not affected by iptables rules... it just ends up going to a different IP/port, NOT a different webpage (i.e. URL, which is specified *within* the HTTP packets). In order to redirect traffic to a different *webpage*, you need to do some serious layer violations (e.g. using string matching on packets), configure your HTTP server accordingly or you need to use an intermediate proxy (in your case a transparent one, most probably) such as squid - NONE of which involves iptables or bridges at all... because I saw that you already had that part set up.

I was actually trying to help you, and to help understand what you were actually asking for and to point you in the right direction. But as far as I'm concerned, you can sod right off now. That's probably why no one else bothered to post after me, either.

P.S. I do this for a living and set up machines to do exactly this thing dozens of times a year, with full HTTP redirection based on a myriad of criteria (e.g. if your MAC/IP isn't recognised, you go to one page on a HTTP server, if your MAC/IP is blocked you go to another, if your MAC/IP is allowed you get full, transparent Internet access etc., if your MAC/IP belongs to a certain room within a school, you get filtered Internet access, all through the same single machine. I was in the middle of cleaning up the scripts I use to do this to add on this post when I read your reply and then thought... bugger it.

Last edited by ledow; 01-14-2009 at 03:33 AM. Reason: Added a PS
 
Old 01-15-2009, 01:08 AM   #5
sholah
Member
 
Registered: Dec 2006
Posts: 34

Original Poster
Rep: Reputation: 15
ledow,

I have it working already...thanks for all ur help.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create the netfilter ip-strings module for a linux linux-2.6.18.2-34 kernel? jeffn Linux - Security 1 01-30-2008 06:39 AM
Netfilter/iptables on Linux Debra Programming 1 10-03-2002 07:40 PM
Netfilter/iptables on Linux Debra Linux - General 2 10-03-2002 07:27 PM
Netfilter/iptables on Linux Debra Linux - Newbie 0 10-03-2002 06:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration