Haverer
Posts: 9
Joined: Thu May 07, 2015 11:29 pm

Wifi Ethernet shared through LAN

Mon Sep 24, 2018 9:53 am

Dear All,
I've tried various tutorials online but I think many are out of date.

My pi 3 is connected to wifi through the built in wifi.
What I want to achieve, is plug a computer into the LAN port, get an IP address by DHCP and then route any internet requests from eth0 to wlan0

I don't want to bridge them so that my other devices all ask the DHCP server that the WiFi connects to. I want a separate network on the eth0 side that the wlan0 devices can't see.

I've downloaded RASPBIAN STRETCH LITE
One of the tutorials I followed didn't work due to this line
nano /home/pi/.config/lxsession/LXDE-pi/autostart

from this tutorial https://raspberrypi.stackexchange.com/q ... ernet-port

I guess that's because I'm using the LITE version?
Does anyone have a step by step to make this project work?

Thanks

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

Re: Wifi Ethernet shared through LAN

Mon Sep 24, 2018 11:46 am

Install dnsmasq.

Code: Select all

sudo apt-get install dnsmasq
Assign eth0 an IP address. Open /etc/dhcpcd.conf with a text editor and add this at the bottom.

Code: Select all

interface eth0
static ip_address=192.168.4.1/24
Save original dnsmasq.conf

Code: Select all

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Open /etc/dnsmasq.conf with a text editor and add this

Code: Select all

interface=eth0
dhcp-range=192.168.4.8,192.168.4.250,255.255.255.0,12h
Edit /etc/sysctl.conf and uncomment

Code: Select all

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

Code: Select all

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

If you have problems with the dhcp service, you can check the status of dnsmasq.conf.

Code: Select all

sudo service dnsmasq status
It should show active (running), and a list of IP assignments to each mac address..

Haverer
Posts: 9
Joined: Thu May 07, 2015 11:29 pm

Re: Wifi Ethernet shared through LAN

Mon Sep 24, 2018 11:53 am

WOW! That looks a lot less compicated than what I was following in other tutorials. I'll give it a go when I'm back at my desk.
Thanks for the time taken to post.
:-)

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

Re: Wifi Ethernet shared through LAN

Mon Sep 24, 2018 12:09 pm

Glad I could help.

I forgot to mention, but this should be obvious, that you need to connect wlan0 to an AP to get this to work.

Also, check ifconfig to ensure the correct IPs are assigned to each interface.

Haverer
Posts: 9
Joined: Thu May 07, 2015 11:29 pm

Re: Wifi Ethernet shared through LAN

Thu Sep 27, 2018 3:01 pm

;-) Now that bit I did get! ;-)
I'm about to attempt the instructions you sent - fingers crossed! ;-)

SurferTim wrote: Glad I could help.

I forgot to mention, but this should be obvious, that you need to connect wlan0 to an AP to get this to work.

Also, check ifconfig to ensure the correct IPs are assigned to each interface.

Haverer
Posts: 9
Joined: Thu May 07, 2015 11:29 pm

Re: Wifi Ethernet shared through LAN

Thu Sep 27, 2018 7:17 pm

Massive thanks for the simple and clear steps. It worked first time. Perfectly. Plugged my wireless AP (obviously with the DHCP off) into the ethernet socket on the pi, instantly everything connected to the AP/switch was online.

Hopefully your instructions will help many more who come across this post :-)

Return to “Networking and servers”

Who is online

Users browsing this forum: No registered users and 14 guests