AN1MuSS
Posts: 1
Joined: Sat Jan 20, 2018 3:27 pm

Raspberry Pi 3 As WiFi Adapter?

Sat Jan 20, 2018 3:32 pm

So, I own a Raspberry Pi3. I know that with it I can create an Access Point using ethernet cable between modem and the raspberry itself, and connect to it via Wireless. I was wondering: can you do the opposite? I mean create an Access Point using wifi to connect raspberry to modem, but using ethernet cable to connect raspberry to the client. In conclusion: use the raspberry like a wifi adapter/dongle for the pc. I hope this will make sense. Also I'm kind of noob with raspberry pi3 so a tutorial or a list of commands with explanation will be very helpful. Sorry for my bad english, I'm italian :) Thanks in advance!

n67
Posts: 839
Joined: Mon Oct 30, 2017 4:55 pm

Re: Raspberry Pi 3 As WiFi Adapter?

Sat Jan 20, 2018 6:43 pm

If I understand you correctly, you are looking for what is usually called a "WiFi bridge".

Assuming this is correct, check out:

https://github.com/SurferTim/documentat ... et-sharing
"L'enfer, c'est les autres"

If a post offends you, just put that poster on your foes list, and be done with it (and with them).

To do otherwise, risks being banned.

SurferTim
Posts: 1763
Joined: Sat Sep 14, 2013 9:27 am
Location: Miramar Beach, Florida

Re: Raspberry Pi 3 As WiFi Adapter?

Sat Jan 20, 2018 8:08 pm

You can set up the ethernet and wireless "backwards".

Connect your onboard wireless to an access point. Ensure you can access the internet from the RPi.

Install dnsmasq and save the original config file.

Code: Select all

sudo apt-get install dnsmasq
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Open a new /etc/dnsmasq.conf file with a text editor and insert this:

Code: Select all

interface=eth0
dhcp-range=192.168.4.20,192.168.4.100,255.255.255.0,12h
.
Add this to /etc/dhcpcd.conf

Code: Select all

interface eth0
static ip_address=192.168.4.1/24
Edit /etc/sysctl.conf and uncomment this line

Code: Select all

net.ipv4.ip_forward=1
Open /etc/rc.local with a text editor and add this above "exit 0"

Code: Select all

sudo iptables -t nat -A  POSTROUTING -o wlan0 -j MASQUERADE
Reboot

n67
Posts: 839
Joined: Mon Oct 30, 2017 4:55 pm

Re: Raspberry Pi 3 As WiFi Adapter?

Sat Jan 20, 2018 8:50 pm

Yeah, now I see more clearly that the page I pointed you to earlier - the one by SurferTim is the opposite of what you want. You want the easier case of "Have wireless - want ethernet".

I used to do this all the time when I was camping and I could only get the wireless from the air if my wireless adapter was in one specific position. So, I would mount it in that position and use it to generate an ethernet connection for use elsewhere.

Anyway, as SurferTim notes, this is easily done using just two components: A DHCP server and "iptables". I used to always do it with busybox's "udhcpd", which is a lot easier to setup and use than dnsmasq (which everybody on this board seems to recommend).
"L'enfer, c'est les autres"

If a post offends you, just put that poster on your foes list, and be done with it (and with them).

To do otherwise, risks being banned.

Return to “Networking and servers”