LinuxQuestions.org
Review your favorite Linux distribution.
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 05-01-2009, 11:01 PM   #1
ninja80
LQ Newbie
 
Registered: May 2009
Posts: 2

Rep: Reputation: 0
Using iptables to create a captive portal


I am working on a class project where we are making a captive portal, before you login to a web page hosted on the gateway all traffic trying to go past the router will not be forwarded.

I have a ubuntu machine set up as the gateway, with a apache hosting the login page.

The page currently will allow user to log in and then it changes the iptables rules to allow the traffic through the gateway... however I am having problems redirecting traffic to the gateway before they log in. What needs to happen is that all http requests before they are loged in are redirected to the login page.

I know there are plenty of programs that do this for me but I am not allowed to use them.

Thanks for any help.
 
Old 05-02-2009, 04:43 AM   #2
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Hi,

Welcome to LQ.

Thank you for being forthright about your problem being a school assignment. I'll be equally forthright and tell you I have never tried to do such a thing! Also, generally it is best (for the student) if a student figures out their own assignment, because that is where learning happens. (Yes, I've struggled with problems both while in "formal education" settings as well as outside such settings. The struggle and mistakes usually teaches you a lot.) But perhaps I can give you a nudge in (what I think!) is the right direction. Please realize I could be wrong, and, in any event, you need to work out the details.

I understandand you have Apache already running with the "login page" available? I suggest that you look at the REDIRECT target (-j REDIRECT) in the PREROUTING table to direct the outgoing request to the login page. You will, of course, have to make sure that users who have already logged in do not get so REDIRECTed. The ipables man page is an excellent source of information about this. (As are Internet search engines.)

Good luck!
 
Old 05-02-2009, 05:13 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
...plus captive portal software is readily available. I'd venture some even come with installation instructions to learn from.
 
Old 05-02-2009, 01:48 PM   #4
ninja80
LQ Newbie
 
Registered: May 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by blackhole54 View Post
I suggest that you look at the REDIRECT target (-j REDIRECT) in the PREROUTING table to direct the outgoing request to the login page. You will, of course, have to make sure that users who have already logged in do not get so REDIRECTed.
Thanks!

I had seen --to-destination and I was trying to use that, but "REDIRECT --to-ports 80" was what I was missing and that works to redirect them. Now I just need to get the syntax right to stop the redirection once they log in.
 
Old 06-08-2009, 10:04 AM   #5
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Oskar Andreasson's "ultimate" iptables tutorial is here.
 
Old 08-01-2009, 10:58 AM   #6
abeverley
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 1
I am assuming that the original poster has now finished their assignment, so for the benefit of anyone else coming across this thread, I have written full details of how to do this here

The page at the link describes how to create a captive web portal using iptables. Traffic is redirected from a client until they signup on a PHP webpage. It uses sudo to allow apache to insert the firewall rules, and importantly also uses conntrack to remove stale connection tracking information after they have signed up. If this is not done, I have found that a user can sometimes still not access the desired website after they have signed up.

Last edited by abeverley; 08-01-2009 at 11:00 AM.
 
1 members found this post helpful.
  


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
Setting up a Captive portal VeeDubbs Linux - Networking 3 05-31-2009 11:55 AM
captive portal opinions needed tanoatlq Linux - Software 0 05-18-2008 05:51 PM
Captive Portal for IPCop waelaltaqi Linux - Networking 0 03-05-2007 10:54 AM
suitable captive portal with ipcop? tzouse Linux - Networking 1 04-05-2006 07:56 AM
captive portal and iptables dutch1918 Linux - Wireless Networking 0 12-16-2005 09:21 AM

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

All times are GMT -5. The time now is 09:08 AM.

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