Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
I'm interested in using my 3 B+ as a pi-hole. The twists are that my internet connection is via an android mobile hotspot and doesn't involve a router of any sort, and that I don't know anything about routers or networks etc.

Can I buy a wireless router that: gets its internet connection from a USB (or wirelessly) connected cell phone, serves this internet connection to the computers and other devices in my house, and connects to my PI for the pi-hole DNS lookups?

Adbot
ADBOT LOVES YOU

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

spiny posted:

if you're current hotspot uses a SIM then, yes, plenty of routers that support connnecting using a 3/4G network.

I've used some of these to give customers emergency internet when their main service is down:

https://www.tp-link.com/uk/products/list-4691.html

These guys seem to require that I remove the SIM card from my phone and insert it into the router. Inconvenience aside, it's not really practical for me to have my calling / text connectivity disabled while sharing internet.

What I'm looking for is a router that I can attach my phone to via USB instead. This one has a USB port for a USB Modem - could that port be running to an Android device instead?

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

Fuzz1111 posted:

A better option I think would be to use the rpi as the router itself, it should be dead easy to tether a rpi running raspbian to your phone via USB - it should just work actually (and you should test this before taking this idea further), if it does I can post more details about setting rpi up to do this.

Posting now from the USB-tethered PI, which 'just worked'. A step in the right direction.

You're suggesting from here that I use the PI as a hotspot for my other devices?

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

Fuzz1111 posted:

Yes that's exactly what I'm suggesting (using rpi's internal wifi for the Access Point). Sorry for delay I had trouble finding the script I wrote ages ago to do something like this. Here are steps to set pi up as wireless router:
  1. Uncomment/add/modify following line in /etc/sysctl.conf:
    code:
    net.ipv4.ip_forward=1
  2. Install hostapd and dnsmasq:
    code:
    sudo apt-get hostapd dnsmasq
  3. Reboot pi.

  4. Download and extract the script and AP config:
    code:
    wget [url]http://fuzz.website/pirouter.tar.gz[/url]
    tar xvf pirouter.tar.gz
  5. Plug in phone, tether, make sure pi has connected, and then run script:
    code:
    cd pirouter
    ./pirouter.sh

Hopefully you should see a new wifi access point called "HELLOHELLO", the password is "passwordhere" (to change these edit hostapd.conf file which came with script). Connecting to it should give you an IP in the 10.42.0.x range, and you should have internet access via the tethered phone. Actually the way I've written the script, the pi will use any available connection as uplink, so it will work just fine for someone wanting to use rpi's ethernet as uplink (infact if your pi has ethernet connection as well as tethered one, it will likely prefer using ethernet instead of tethered phone as uplink - let me know if this is a problem for you).

I should note that the script stops networking service so if uplink connection is not made before running script (or dies after) this will cause problems - there's some lines commented out in the pirouter.sh script that might help for that.

Let me know how you go.

Hey, thanks for this. I'm making progress, but haven't achieved the ultimate goal yet. Your script works (broadcasts a network, shares the internet connection) when pihole is not running, but only works partially when pihole is running (broadcasts a network, but connected devices aren't getting an internet connection through it - "No Internet, secured").

This is the output from your script when it's run while pihole is enabled:

code:
dnsmasq: no process found
RTNETLINK answers: File exists
Configuration file: hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
wlan0: Could not connect to kernel driver
Using interface wlan0 with hwaddr b8:27:eb:26:85:a1 and ssid "HELLOHELLO"
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED 

dnsmasq: failed to create listening socket for 10.42.0.1: Address already in use
It's unclear to me whether the failure in the last line is a leftover from a previous run of the script, or due to interference from pihole. Still poking at it myself, but figured I would share my progress so far in case more knowledgeable eyes can save me some time.

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.

Fuzz1111 posted:

Oh that's right you're wanting to use pi-hole. Yeah my script uses dnsmasq for both dhcp and dns, while pi-hole just uses it for dns but can optionally enable dhcp too.

Easiest way to fix this is to let pi-hole do both - comment out the lines in my script that have anything to do with dnsmasq (so the line that stops service, the line that kills process, and the line that starts it). Then enable the dhcp server in pi-hole's gui with following settings (has to be these ip's so my script will do actual routing bits successfully):


Hopefully that works, but let me know if it doesn't and I'll go over doing this the other way (disabling only dns part of my script, but not dhcp).

[edit]
I recommend trying above first, but after looking at dnsmasq's options - it's actually kind of simple to do it the other way too: instead of commenting whole dnsmasq command line out just add "-port 0" to the end of it (apparently that's all that's needed to prevent it starting a dns server). You'll still have to remove the lines that stop the dnsmasq service and kill it because those will interfere with pi-hole's instance of dnsmasq - unfortunately this means my script can't be executed multiple times without cleaning up the instance of dnsmasq it leaves behind manually first (you'll have to use kill -9 and ensure you are killing the instance started by my script, not the instance started by pi-hole).

I won't have a chance to try this until the weekend, but thanks in advance. Will report back.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply