LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 08-19-2011, 09:19 PM   #1
slac-in-the-box
Member
 
Registered: Mar 2010
Location: oregon
Distribution: slackware64-14.1
Posts: 160

Rep: Reputation: 26
slackware specific help for cgi script


howdy slackers:

Although my question doesn't pertain specifically to the installation or evaluation of slackware, my home network has multiple servers which all run slackware, and I have a problem for which I wish for a slackware-specific solution, so I post here instead of a broader LQ forum.

In a nutshell, I need help with a cgi script. The details: I live in the mountains, and am fortunate to have DSL in a region where cellular phones do not work. My neighbor is currently hosting an event that brings about 800-1200 folks camping out on his land, all withing wifi range of my home. They asked me to share my DSL via wifi with general public.

I want to take it a step further, and provide a welcome page, with map of area, local land use regulations, etc., as well as some other terms and conditions that they must consent to to use my wifi (standard legal disclaimer, etc.)...

To accomplish this, my network is arranged thus:

Code:
 (DSL-ROUTER)
                |
              bridge
             /      
    public switch    priv.switch
          /      \       |
        static    dhcp-server
       addresses:              \
         www                    \ 
       asterisk                  wifi bridge 1
        mysql                                 \
         bind                                  \
                                                wifi bridge 2

this could be all wrong... I'm just a hobbiest...

But... I created an html page on the apache web server, www, that is listening on a LOCAL address on the private switch. This page informs the guests of the rules, and then offers up simple html form button to click on if they agree to terms.

My plan is to use IPTABLES on the dhcp-server to route all oubound port 80 traffic that is not on a list contained in a file somewhere to the local welcome page.

I need help with the choice of a solution for a cgi script to process the html form when they click "agree" on the local welcome page. This script should get their ip address or MAC address, and add it to the list contained in the file somewhere. Thus once they're on the list, they will no longer get the welcome page, but will have NAT...

what is a quick and dirty way with tools that are in a default full install of slackware (perl, php, lisp, javascript, whatever) to create a cgi script to get the ip address or mac address to add to the file for ip tables...

or am I completely off base and there be some more efficient way of doing this, or software that already does it that I can just install...

thanks in advance for any input

Last edited by slac-in-the-box; 08-20-2011 at 03:34 AM.
 
Old 08-20-2011, 03:32 AM   #2
slac-in-the-box
Member
 
Registered: Mar 2010
Location: oregon
Distribution: slackware64-14.1
Posts: 160

Original Poster
Rep: Reputation: 26
oh...


well there were some sample cgi-scripts that came with the apache bundled in slackware, one of them called test-cgi, which printed the environmental variable REMOTE_ADDR, and so I can now get ip address...

maybe there is way to use ip to look up MAC address... hmm...

still trying
 
Old 08-20-2011, 09:55 AM   #3
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 227Reputation: 227Reputation: 227
Code:
ip_add="192.168.0.64"
arp -a |awk /$ip_add/'{ print $(NF-3)}'
Will let you use built in tools or you could grab "arp-scan" from Slackbuilds and do something like...

Code:
ip_add="192.168.0.64"
arp-scan --quiet -I eth0 192.168.0.64 |awk /$ip_add/'{ print $NF}'
What you are actually doing is making a "Captive Portal". The free version of Untangle Gateway has this functionality built in if you want another option.

Last edited by mRgOBLIN; 08-20-2011 at 10:14 PM. Reason: changed br0 to something a little more standard =)
 
1 members found this post helpful.
Old 08-20-2011, 01:54 PM   #4
ponce
Senior Member
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 2,409

Rep: Reputation: 853Reputation: 853Reputation: 853Reputation: 853Reputation: 853Reputation: 853Reputation: 853
I've tried nocatauth in the past and it works fine for capturing natted hosts, the only thing is that like most captive portal solutions it's not that easy to setup

http://nocat.net/

but like mRgOBLIN says, there are many dedicated gateway/firewall distributions that have this functionality included and ready to use, you can have a look also to pfsense or zeroshell.
 
Old 08-20-2011, 03:12 PM   #5
slac-in-the-box
Member
 
Registered: Mar 2010
Location: oregon
Distribution: slackware64-14.1
Posts: 160

Original Poster
Rep: Reputation: 26
TY mRgOBLIN... that code get's mac address beautifully!

I know there are live cds and distros made for this... and now that I learned the term "captive portal" I've discovered more... but there is nothing like understanding how it's happening, which is why I'm sticking with slack...

So, now equipped with MAC address, I feel like it's time to back up my /etc/rc.d/rc.firewall script, which was created with easy firewall generator, and start experimenting with capturing outbound traffic to port 80 and getting it to the local apache welcome page...

I used to do this with openbsd's pf, but got tired of keeping up with a separate distro just for the firewall, and so am trying to learn to do it all with slack. Deep thanks to the slackware community for its patience, help, and support.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
calling CGI script in CGI script ravi_chobey Programming 3 03-19-2009 12:36 PM
i get an error message running php script inside a cgi script. repolona Linux - Software 0 02-22-2007 09:10 PM
Directory listing - Calling shell script from a CGI script seran Programming 6 08-11-2005 11:08 PM
python cgi script and premature end of script headers Neruocomp Programming 1 07-28-2005 11:43 AM
CGI script: username specific hamish Linux - Software 1 01-17-2005 08:00 AM


All times are GMT -5. The time now is 12:05 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration