How does redirect to the PirateBox Menu work?

Posted by Mattef 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Now, this forum is in read-only mode. You find details Details hereContinue on /r/PirateBox
How does redirect to the PirateBox Menu work?
September 29, 2013 10:19PM
Hello!

I recently installed OpenWrt to my Wr703n Router and now I want to redirect
every web traffic to a specific site on my router, in just the same way how it does the pireatebox.
I don't want to install piratebox (I know it is good, though), because there are a lot of services running
and preferences set, that I don't want to lose.
Also an lighttpd server is running on port 81, and I can manually call the website I want the user to be redirected on,
at 192.168.0.1:81.

So, how does redirect on the PirateBox actually works?

An intense google search doesn't gave the results, that I wish, just some gibberish about
iptables and so on. Nothing actually worked for me.

I hope someone can help me a little bit.
- Matthias
Re: How does redirect to the PirateBox Menu work?
September 30, 2013 06:08PM
Hi Matthias!

The PirateBox scripts handle browser-requests which contains out of two parts, which are:

1. the domain
2. the specific url

in you case on top: 3. redirect to a different Port

With a modification in the dnsmasq configuration, you enable the domain-redirect to 192.168.0.1
If you want to do it via configuration file, you might need to do some effort to bring that parameter "through" uci. "cr" made that hack on the first OpenWRT release and you can find that here: [github.com] line 159-167
Maybe you need some additional parameters, because If your PBx is still connected to the interet, it may resolve still with the correct IP

After you did these changes, all clients servered by your piratebox will resolve any domain to 192.168.0.1 - double check this with nslookup or any equivalent tool.

Point 2 and 3 are somehow connected with eachother.

I start explaining point 2, and then you get an idea what the problem about port 81 is.

If you enter google.com, the dns resolves now 192.168.0.1 which points to your (web)server running at port 80 url /
In case of PirateBox this should deliver the Piratebox splash-page. If you use a search-bar or hit a facebook-url you get something like:
[google.de]

Now, we need a redirect which redirects "fjgjsfglkglfkjgdkfjgdlkjg" back to /, ideally to piratebox.lan/ that we don't poison the browser-cache too much. I solve this with a specific 404 page.

in a way like that, you maybe able to redirect your users to Port 81, but for that you have to change the stuff running under Port 81.

Then you can do a redirect on the wifi interface from Port 80 -> Port 81 via IPTables.

Last but not least, you can run something like nodogsplash which gives a specific entry page and redirect from there down to your piratebox-ip + port. In this case, you mess alot with the configuration with your box and it maybe still won't work like you expect :/

Does that anyhow helps? Still questions, don't hestinate and ask.

sincerly, Matthias
Re: How does redirect to the PirateBox Menu work?
October 03, 2013 04:33PM
Hello Matthias! smiling smiley

Thanks alot for your reply!
I don't understand how the hack ist actually working. In my case there is no function called "pb_netconfig()", so I don't know where to put the lines.
Also I tried to run the command

sed -i 's#^.*\${fqdn\%\.\*}\" ==.*$## ; s#^.*fqdn=\"\$fqdn.*$##' \
/etc/init.d/dnsmasq

in terminal, but nothing changed.
Can I put the script piratebox.common into the dir /etc/init.d/ and start it via "/etc/init.d/piratebox.common start" without messing with my installation? I doubt that.
Maybe you can give me some additional hints winking smiley

Cheers,
Matthias
Re: How does redirect to the PirateBox Menu work?
October 03, 2013 07:44PM
Hi,
well, the piratebox.common script does this change only once on startup. I don't even know what the sed does, but as far I understand it enables the init.d script to work with the # in the configuration.
Did you compare the init.d or how did you find out that it didn't changed anything? A successfully sed command don't print any output.

even the pirateox scripts won't help u much, may mess more things up....

regards
Matthias
Re: How does redirect to the PirateBox Menu work?
October 03, 2013 09:19PM
Hmm, maybe I should give the script one more try and compare init.d bevore and after running the sed command.
I thought the script would change something in the behavior of the internet connections and as nothing changed, I thought it hasn't worked.
But now it is late in Germany so I will try this tomorrow winking smiley
I' ll keep you up tu date!
- Matthias
Re: How does redirect to the PirateBox Menu work?
October 04, 2013 06:50AM
You can join #piratebox too.. I'm from Germany too and to normal times online smiling smiley