PBox on existing LAN with RPi b

Posted by ogliastrino 
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
PBox on existing LAN with RPi b
October 05, 2016 04:48PM
Hi everyone, this is my first post, so correct me if i make mistakes.

I need help with my setup, which is this:

i have installed PBox on my Raspberry Pi and as an AP it's working perfectly. but i would like to make it work in my existing lan, basically acting as a dhcp client to my main router but dns server, so when i type in "piratebox.lan" i go to the local page, but if i type anything else the dns request is sent to (for example) google's 8.8.8.8

to this point i modified the config files so that the AP mode is disabled and eth0 is the selected interface. so if i type in a browser "internal ip/content" i access the main page (but the file upload isn't working). Now if i set the dns server of my main router to the RPi's ip, the redirection works but the landing page (piratebox.lan/content) is not reachable (as is every other page, it predictably says "dns not resolved" ).

I tried messing with the dnsmasq, hosts and resolv config files, but didn't manage to understand which is the effectively used file (/etc/dnsmasq.conf or /opt/piratebox/.../dnsmasq_generated.conf and so on), so after many hours of tinkering, i gave up and resolved to ask for help here.

Thank you

Diego
Re: PBox on existing LAN with RPi b
October 05, 2016 07:19PM
Hi Diego,
welcome to the forum.

The problem you are facing has nothing to do with the PirateBox configuration.

As you said, the PirateBox can be reached with

Language: PHP
http://<RPi IP>/content
The upload box can be reached via
Language: PHP
http://<RPi IP>:8080

The issue is, that your client - connected to your homenetwork, does not resolve the piratebox.lan name. Your router from the homenetwork, which gives away IP addresses, simply does not know about the piratebox. If you are lucky, you can access the box with
Language: PHP
http://alarmpi/content http://alarmpi:8080/content
The next iteration is to set the RPi's hostname to "piratebox". But that will only make the urls to the following list
Language: PHP
http://piratebox/content http://piratebox:8080/content
The upload box still need manual tweeking. From this point, you might edit the main.html file and change the URL of the iframe to "piratebox" only, that may make it.

Another option is to modify the computer you are sitting in front of to resolve piratebox.lan always to your piratebox-rpi IP in the homenetwork. (If linux, it is an entry in /etc/hosts)
Or add a manual entry "piratebox.lan" in your homenetwork router which points to the RPi's ip... but this is very unlikely possible.

I also recommend to revert your changes in hostap & dnsmasq settings, because it may break your home network smiling smiley

Hope that helps a bit,
best regards
Matthias
Re: PBox on existing LAN with RPi b
October 06, 2016 07:20AM
Hi Matthias, thank you for the fast reply.

Ok so if i don't use an openwrt home router (that allows me to set local hostnames in /etc/hosts) i have to configure every device (pc/smartphone) to resolve the hostname, or directly change the hostname to "piratebox" (without .lan).
I am thinking for now to keep the AP mode working, because i will be the only experienced user that knows that to upload you have to go to the 8080 port.

Another possibility that i'd rather not implement but would be possible is that i disable completely the dhcp in the existing modem/router and use it just as modem and switch/AP, but then i would have to set the RPi to resolve just
Language: HTML
http://piratebox.lan
to the local ip and disable the redirection, so the clients would still be able to reach "the internet" (which as i said before was my ultimate goal, but at this point i am starting to think that it isn't feasible)

Thanks
Diego