LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-25-2010, 04:43 AM   #1
rexjenny
LQ Newbie
 
Registered: Apr 2006
Posts: 18

Rep: Reputation: 0
iptables redirection


Hi,
Am new to iptables. So if this question sounds bizarre please forgive me. We have two Squid proxy servers running in "non-transparent mode" (172.16.0.1 and 172.16.0.2). Currently users have to configure the proxy server they want to use by configuring them in their browsers. Recently I saw an example for redirecting web traffic to a single transparent proxy server.

-A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
-A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3128

Can anyone modify this rule to accommodate my current setup of two proxy servers running in non-transparent mode. i.e Redirect web traffic to the 172.16.0.1-172.16.0.2 ip range. Advanced thanks for the help.
 
Old 03-25-2010, 10:32 AM   #2
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14, Ubuntu 12.04/12.10, FreeBSD 9.0
Posts: 1,571

Rep: Reputation: 92
What kind of OS is on users computers?
 
Old 03-26-2010, 08:55 AM   #3
rexjenny
LQ Newbie
 
Registered: Apr 2006
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nimnull22 View Post
What kind of OS is on users computers?
First of all thanks for showing interest. Regarding your question students have all Windows family OS, Apples MACs, nix based distributions etc. Ours is a college, where a laptop/wireless user after obtaining an ip from a Wireless AP will have to configure either one of these proxy server address in there browsers to get web access. There is no authentication involved in this scheme meaning anyone with a laptop or wireless device can access the web. To resolve this we like to introduce authentication in our setup so that we can track users. "Squid NTLM Authentication against Active Directory" is one way to do this but it needs a costly Windows 2003 Server license which we cannot afford. Another solution is to run a "Captive Portal" which intercepts http/https requests and redirect them to a login page for authentication. The two lines i previously quoted in my earlier post are part of this script which has been modified so that, after successful user authentication users will be redirected to the lone squid proxy running in transparent mode. My question is, is it possible to redirect web traffic (http/https) to two proxy servers using iptables. (for example using ip range iptables -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-destination 172.16.0.1-172.16.0.2)

# Generated by iptables-save v1.2.8 on Tue Jan 31 20:19:08 2006
*filter
:INPUT DROP [98:9891]
:FORWARD ACCEPT [62452:12516145]
:OUTPUT ACCEPT [28235:10386076]
:LOGDROP - [0:0]
-A LOGDROP -j LOG
-A LOGDROP -j DROP
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i eth1 -p tcp -m tcp --dport 22 --tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A INPUT -i eth1 -p udp -m udp --dport 1812 -j ACCEPT
-A INPUT -i eth1 -p udp -m udp --dport 1813 -j ACCEPT
-A INPUT -i eth1 -p udp -m udp --dport 1814 -j ACCEPT
-A INPUT -i eth1 -j LOGDROP
-A INPUT -p tcp -m tcp --dport 80 --tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 --tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3990 --tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A INPUT -p tcp -m tcp --dport 3128 --tcp-flags SYN,RST,ACK SYN -j ACCEPT
-A INPUT -i lo -j ACCEPT -A INPUT -i eth0 -j LOGDROP -A FORWARD -i eth0 -j LOGDROP
-A FORWARD -o eth0 -j LOGDROP COMMIT
# Completed on Tue Jan 31 20:19:08 2006
# Generated by iptables-save v1.2.8 on Tue Jan 31 20:19:08 2006
*nat
:PREROUTING ACCEPT [4569:305698]
:POSTROUTING ACCEPT [415:33518]
:OUTPUT ACCEPT [634:47605]
-A PREROUTING -d ! 192.168.1.1 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
# Transparent proxy do not work on https
#-A PREROUTING -d ! 192.168.1.1 -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3128
# SSH
-A POSTROUTING -o eth1 -p tcp -m tcp --dport 22 -j MASQUERADE
# Direct access to JCT squid
-A POSTROUTING -d 147.161.1.25 -o eth1 -p tcp -m tcp --dport 3128 -j MASQUERADE
# DNS
-A POSTROUTING -o eth1 -p tcp -m tcp --dport 53 -j MASQUERADE
-A POSTROUTING -o eth1 -p udp -m udp --dport 53 -j MASQUERADE
# POP IMAP
-A POSTROUTING -o eth1 -p tcp -m tcp --dport 993 -j MASQUERADE
-A POSTROUTING -o eth1 -p tcp -m tcp --dport 995 -j MASQUERADE
-A POSTROUTING -o eth1 -p tcp -m tcp --dport 110 -j MASQUERADE
-A POSTROUTING -o eth1 -p tcp -m tcp --dport 143 -j MASQUERADE
# SMTP
-A POSTROUTING -o eth1 -p tcp -m tcp --dport 25 -j MASQUERADE
-A POSTROUTING -o eth1 -p tcp -m tcp --dport 587 -j MASQUERADE
# https
-A POSTROUTING -o eth1 -p tcp -m tcp --dport 443 -j MASQUERADE
COMMIT
# Completed on Tue Jan 31 20:19:08 2006
 
  


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
IPTables redirection hazza96 Linux - Networking 8 02-16-2009 01:57 AM
iptables redirection? prayag_pjs Linux - Newbie 3 04-16-2008 11:10 PM
iptables redirection mallikk_in Linux - Networking 11 09-02-2007 01:00 AM
Help:iptables redirection swmok Linux - Networking 2 11-24-2004 07:47 AM
IPtables Redirection Exception? BoarderX Linux - Networking 7 09-22-2004 06:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:53 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