WiFi to ethernet adapter for an ethernet-ready TV

tv4e

THIS PROJECT, AND THE AMENDEMENT BELOW ARE NOW REPLACED BY A NEW UP TO DATE VERSION YOU CAN FIND HERE
**********************************************************************************************

IF YOU ARE INTERESTED IN TRYING OUT THIS PROJECT THEN PLEASE READ THE AMENDMENT PUBLISHED ON MAR 19th 2015 HERE

I have an internet ready Panasonic TV which can connect via a wired ethernet cable to a suitable internet-connected router, or via a wireless connection using a Panasonic usb wifi Dongle. Unfortunately this is quite expensive in the region of £50-£60 pounds and I couldn’t justify the expense for the limited number of times I might use it. However, it occurred to me that it should be possible to build a wireless to ethernet adapter using a raspberry pi.

If you do not want to wade through the whole article (although I hope you will) you can jump to the end where a zip file is available to download with instructions to enable you to get up and running quickly

I had previously built a wireless access point using the Rpi based on the Pi-Point Article amended according to the article by Jens Segers to allow for the fact that I was using an Edimax EW-7811Un wireless adapter which requires a special modified hostapd. (The basis of these articles has been nicely brought together by Dave Conroy in a form which is much easier to follow here. What I now required was basically something working in the opposite direction.

I Googled the topic and found a project  by Glenn Lockwood to configure a Raspberry Pi as a Wireless-to-Wired Ethernet Bridge…just what I wanted Most of the work is contained in his article which is excellent, but I found one major gotcha which caught me out and took some time to solve. There were also one or two points which could be made a bit clearer, and I will take the opportunity to start from scratch in developing this project with full step by step details to make it easy for you to follow.

What you need:
A Raspberry Pi Model B (256 or 512Mb is ok) and psu
An SD card 2Mb or larger and a usb SD card reader (if your PC does not have an SD card slot)
A usb WiFi adapter. I used the Edimax  EW-7811Un currently £7.95 from play.com
and ethernet cable to connect the Rpi to the TV

A PC or Mac with a card reader to enable you to setup the SD card.

I assume that you also have an internet connection via a wireless broadband router with a spare ethernet socket into which a PC (or Rpi) can be plugged. In my case this is a Netgear DGND3300v2. This router should be set up to configure attached computers via DHCP, i.e. to automatically configure its network IP address and DNS etc, By default the Rpi expects this to be the case when an ethernet cable is plugged in to its ethernet port,

Stage one: Setting up your RaspberryPi SD card
Install the latest Raspian distribution onto the SD card. You can download it here onto your PC (currently latest is 2013-05-25-wheezy-raspian.zip)
You then unzip it (on Windows 7 right click on the zip file and select extract all)
Also downloaded Win32DiskImager from here, again unzipping the downloaded file
insert your SD card into the usb card reader and plug this into a free usb slot on your PC.
Note carefully which drive it mounts on (in my case drive F)
Now run Win32DiskImager by double clicking the unzipped file
insert your SD card note you can double click any image to see a larger copy, and then use the back button on your browser to return
win32diskimager
select the correct drive letter for your SD card…Be certain you get this right
and click the blue folder icon to navigate to the wheezy-raspian image
Then click the Write button, acknowledge the warning dialog that pops up and you will write the image to your SD card which will take a minute or two. You should get a dialog box saying Write Successful when it completes.
quit the win32DiskImager program and you should see your SD card in the relevant drive (F). it will contain the Boot partition for the raspberry PI. About 40Mb or so of files.
Eject the card from the PC and insert it into your Raspberry Pi.

Stage 2: Booting the Raspberry Pi and setting up the network interfaces
Initially it is easiest to set up the Rpi with an hdmi monitor connected, together with a keyboard and mouse, and an ethernet cable connected to your router. Leave the usb WiFi adapter aside to start with.
Plug in the SD card, and connect the power, and all being well the Rpi should boot up and show the raspi-config screen. This lets you carry out some initial configuration.raspi-config
Working through the choices,:
1: select Expand the Filesystem. It won’t have much effect if you are using a 2Gb SD card, but will give you extra free space if you have a bigger capacity card.
2: Change the user password for the pi user, from the default raspberry to something else you can remember
3: leave the option boot to desktop unset. Since we will not use the desktop for this project we want the Rpi to boot to command line
4: Set the time-zone appropriate for your location (I chose Europe, London)
5: Although I have a camera on my Rpi, you probably won’t want one on this project so you can leave unset
6: Ignore 6 just now
7: ignore 7. no need to overclock for this project
8: select option 8 and adjust Memory split so that only 32Mb is allocated to the GPU. We won’t be using graphics so it is better to have more memory for other purposes
Also enable ssh. This will enable us to talk to the Rpi directly from our PC later, which is convenient when setting it up.
now use the right arrow key to select finish and press return, Select the default Reboot and press return again
When the boot process completes, log in as the user pi with your newly chosen password

The first thing to check is that your Rpi is connected to the network and the internet.

Type ping google.com press return and you should see something like the following
terminate the process by typing ctrl+C (shown as ^C)

pi@raspberrypi ~ $ ping google.com
  PING google.com (173.194.41.69) 56(84) bytes of data.
  64 bytes from lhr08s01-in-f5.1e100.net (173.194.41.69): icmp_req=1 ttl=56 time=11.1 ms
  64 bytes from lhr08s01-in-f5.1e100.net (173.194.41.69): icmp_req=2 ttl=56 time=11.3 ms
  64 bytes from lhr08s01-in-f5.1e100.net (173.194.41.69): icmp_req=3 ttl=56 time=11.2 ms
  64 bytes from lhr08s01-in-f5.1e100.net (173.194.41.69): icmp_req=4 ttl=56 time=10.7 ms
  ^C
  --- google.com ping statistics ---
  4 packets transmitted, 4 received, 0% packet loss, time 3005ms
  rtt min/avg/max/mdev = 10.797/11.120/11.307/0.198 ms
  pi@raspberrypi ~ $

This shows that packets are travelling to and from google.com on the internet

find out the ip address allocated to your Rpi by typing the command ip addr

pi@raspberrypi ~ $ ip addr
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
  2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
  link/ether b8:27:eb:8e:b7:42 brd ff:ff:ff:ff:ff:ff
  inet 192.168.1.17/24 brd 192.168.1.255 scope global eth0
  pi@raspberrypi ~ $

This shows the adapter eth0 has (in my case) an ip address 192.168.1.17
(the address you get will depend upon the range of addresses that your router is set up to serve by DHCP. In my case it is in the range 192.168.1.10 to 192.168.1.50 Other routers may have for example ranges of 192.168.0.10 to 192.168.0.50 or 10.0.0.18 to 10.0.0.50 or 10.0.1.10 to 10.0.1.50) In most cases you can configure the range. If you have a different range you may have to alter some of the addresses used later when we configure the wireless adapter on the Rpi

At this stage I prefer to work from my main computer and to use an SSH connection to the Rpi. SSH stands for Secure Shell and is a way of connecting to the Rpi from an external computer via a network connection as if you were typing directly on the Rpi locally.

On a PC the easiest way to do this is to download a program called putty from here. Choose the link to putty.exe and download it to your PC
Double click the putty.exe file and accept that you want to run it
Add the Rpi ip address in the Host Name (or IP address) box
Type Rpi in the Saved Sessions box and click save. (This is to make it quicker next time you open the link)
putty1
Then click Open  You will see the warning below, to which you respond Yes
putty2
now log in to the Rpi using the username pi and your saved passwordputty3
All being well you will see a similar screen to the one below
putty4
On a Mac computer you don’t need putty. The built in Terminal App has an option to open an SSH connection. Just start terminal and in the resulting window you can type
ssh pi@192.168.1.17 and press return, filling in the password when prompted.

Now that we have a SSH connection to the Rpi we can dispense with the connected keyboard, mouse and use it “headless”. To do this in your putty or mac ssh terminal type
sudo shutdown -h now
and press the return key. This will shut down the Rpi and break the ssh connection
Switch off the power to the Rpi, remove the keyboard and mouse (you can retain the monitor if you wish just now) and plug in the WiFi usb adapter
Reconnect the power to reboot the Rpi.
When the boot process is complete and the login pormpt is showing on the monitor reconnect via SSH using putty (or your Mac)
When you start Putty you can select Rpi and load in the details to save typing before clicking on Open, and logging in as pi with your password

Now we are going to setup the Wireless connector which uses the interface wlan0
To do this we need to edit the network interfaces file. This is in the directory /etc/network To do this we will use the built in editor called nano
In case of accidents we will first backup the existing configuration file

Type the following commands  (as shown in the illustration below)
cd /etc/network
ls
sudo cp interfaces interfaces.bak
ls
sudo nano interfaces

grab1
This opens up the nano editor with the existing contents of the interfaces file
grab2
u
se the arrow keys to move down to the end of the file, then press the back arrow key (above return key) to delete the last three lines of text
iface wlan0 inet manual to iface default inet dhcp

Then add the lines below

iface wlan0 inet static
 address 192.168.1.98
 netmask 255.255.255.0
 broadcast 192.168.1.255
 gateway 192.168.1.1
 wpa-ssid "XXXXXXXXXXX"  (substitute your values for xxxxxx in these two lines)
 wpa-psk "XXXXXXXXXXXX"
 wpa-group TKIP CCMP
 wpa-key-mgmt WPA-PSK

after allow-hotplug wlan0
to give a screen like the one below

grab3


Note the blacked out sections contain the name of your router WiFi ssid identifier and the pass phrase (psk) to enable a computer to connect to it. These will be the same as you used when connecting any wifi computer to your router. Substitute your own values
Now type ctrl+o to write out the modified interfaces file, followed by pushing the return key, followed by ctrl+x to exit the editor. If you type cat interfaces you should see the contents of the file as below

auto lo
iface lo inet loopback
 iface eth0 inet dhcp
allow-hotplug wlan0
 iface wlan0 inet static
 address 192.168.1.98
 netmask 255.255.255.0
 broadcast 192.168.1.255
 gateway 192.168.1.1
 wpa-ssid "XXXXXXXXXXX" (XXXXXXX will have your own values instead)
 wpa-psk "XXXXXXXX"
 wpa-group TKIP CCMP
 wpa-key-mgmt WPA-PSK

The additional lines will set up the wireless interface (wlan0) with a static or fixed address, in this case 192.168.1.98 I have chosen this address as  it is on the same network as the addresses served by the router when using dhcp, but outside that range (192.168.1.10 to 92.168.1.50), so there is no chance of another computer being allocated the same address
If your router serves a different range you will have to choose your own appropriate address here. The broadcast address is used to address all computers on the same network, and the gateway is the address to which packets are routed when the address is not on the same network, e.g. Google’s address 173.194.41.69 used in the earlier ping example.
The wpa-ssid and wpa-group entries should contain the values appropriate to your own wireless router
The best way to activate the new settings is to reboot the Rpi by typing
sudo shutdown -r now
the -r parameter causes it to reboot. Previously we used -h to halt the Rpi i.e. shut it down

all being well, when the Rpi reboots on the hdmi monitor you should see that two ip addresses are displayed at the end of teh boot sequence. In my case

192.168.1.17 and 192.168.1.98 these being the dhcp supplied 192.168.1.17 address for eth0 and the static address 192.168.1.98 for the wlan0 interfaces

If you reconnect via ssh as previously described and type ip addr

you will see something like this

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
  link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  inet 127.0.0.1/8 scope host lo
 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
  link/ether b8:27:eb:8e:b7:42 brd ff:ff:ff:ff:ff:ff
  inet 192.168.1.17/24 brd 192.168.1.255 scope global eth0
 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
  link/ether 80:1f:02:8a:05:cf brd ff:ff:ff:ff:ff:ff
  inet 192.168.1.98/24 brd 192.168.1.255 scope global wlan0

showing details of the internal loopback address and the two external eth0 and wlan0 interfaces

Stage 3 reconfiguring the ethernet eth0 interface

Now that we have the permanent static address setup for the wireless interface, we can connect to the Rpi through that, and the reassign the ethernet eth0 connection to a separate network to which the tv will be connected. I have chosen to use the network 192.168.2.0 and allocate 192.168.2.1 to the Rpi. Later the TV will get an address which will be on the same new network.

First we set up the new ssh connection. Close the existing ssh connection by typing exit and then restart putty and setup a connection to 192.168.1.98 (you can save the settings as RpiWlan as we did before for Rpi and the 192.168.1.17 address)

Open it and connect with username pi and your usual password

(in the case of a Mac simply type ssh pi@192.168.1.98 in a terminal window)

In both cases accept the new credentials as we did when first connecting to 192.168.1.17

Now we need to return to the interfaces file and amend it.

type cd /etc/network
sudo nano interfaces
to load the file into the nano editor as before

Alter the file so that it reads

# The loopback network interface
 auto lo
 iface lo inet loopback
# the internal (wired) network interface
 allow-hotplug eth0
 iface eth0 inet static
  address 192.168.2.1
  network 192.168.2.0
  netmask 255.255.255.0
  broadcast 192.168.2.255
  gateway 192.168.2.1
# the external (wifi) interface
 allow-hotplug wlan0
 iface wlan0 inet static
 address 192.168.1.98
 netmask 255.255.255.0
 broadcast 192.168.1.255
 gateway 192.168.1.1
 wpa-ssid "XXXXXXXXXXX" (insert your own values for XXXXXX in these two lines)
 wpa-psk "XXXXXXXXXX"
 wpa-group TKIP CCMP
 wpa-key-mgmt WPA-PSK

Notice that we have added some comment lines starting with a # to help understand the three different sections of the file

nano hints
To insert a blank line, move to the beginning of a line and press return
To delete a line position the cursor on the line and press ctrl+k

use the backspace arrow to delete characters
When you have finished amending the file use ctrl+o to write out the amended file, selecting the existing filename to overwrite by pressing return. Then select ctrl+x to exit the editor

you can type cat interfaces to check the file contents

if you spot a mistake just use sudo nano interfaces to edit the file again

Once you are happy unplug the ethernet lead, as we can no longer connect via eth0 to our normal network and reboot the pi (sudo shutdown -r now), then reconnect via ssh

on the Rpi monitor you should see two ip addresses shown at the end of the boot process 192.168.2.1 and 192.168.1.98

stage 4 Setting up forwarding and NAT

We now have the correct addresses setup on our two network interfaces. we need to concentrate on how they are connected together. We want packets sent from the TV on the 192.168.2.0 network to travel across to the 192.168.1.0 network connecting to it via the wlan0 interface on 192.168.1.98 Any responses to traffic it sends out have to be rerouted back to the 192.168.2.0 network and travel back to the TV via the wired eth0 interface.

The two networks have different address ranges, so a process called NAT or Network Address Translation is carried out whereby packets from the TV are coded up to appear to come from 192.168.1.98  When replies come to these packets they have the address 192.,168.1.98 stripped and are returned to the originating TV on 192.168.2.100. Just as devices on the internet cannot see your PC directly, but only the router through which it connects to the internet, neither can devices on your normal network see the TV directly.

The rules which govern this transfer of packets and the translation are generated by a package called iptables which is included in the raspian distribution. Full details of how the rules work goes a bit beyond the scope of this article, but there are numerous places on the internet where you can get more information about how they work, such as this one

The rules are stored in memory, and are normally lost when you reboot, so it is necessary to store them so that they can be reloaded, which is done conveniently every time the network interfaces are reinitialised.

The rules can be entered manually one by one, but it is more convenient to write a bash script, which is really just a list of commands which are executed one after another to carry out the same process more easily.

The rules are held in tables, and if you are going to play around with these it is a good idea to start with a script which will reset everything to the default setup with no rules in place.

I found the script below which does this job

#!/bin/sh
 IPTABLES="$(which iptables)"
# RESET DEFAULT POLICIES
 $IPTABLES -P INPUT ACCEPT
 $IPTABLES -P FORWARD ACCEPT
 $IPTABLES -P OUTPUT ACCEPT
 $IPTABLES -t nat -P PREROUTING ACCEPT
 $IPTABLES -t nat -P POSTROUTING ACCEPT
 $IPTABLES -t nat -P OUTPUT ACCEPT
 $IPTABLES -t mangle -P PREROUTING ACCEPT
 $IPTABLES -t mangle -P OUTPUT ACCEPT
# FLUSH ALL RULES, ERASE NON-DEFAULT CHAINS
 $IPTABLES -F
 $IPTABLES -X
 $IPTABLES -t nat -F
 $IPTABLES -t nat -X
 $IPTABLES -t mangle -F
 $IPTABLES -t mangle -X

you can set this up in the home directory for the user pi by typing
cd ~/ (in the ssh terminal window)
nano resetiptables

and then copying and pasting the script into the nano editor window and saving the file as detailed previously. [You can copy by selecting the text and using ctrl+C (PC) or command+C (Mac) then right click to paste in Putty or right click and choose paste (Mac) ]

You can check if it works by typing cat resetiptables to list the script. If it hasn’t worked you can delete the file with rm resetiptables and try again

the script sets IPTABLES to the address of where your iptables program is (/sbin/iptables) and then repeatedly calls the program with the following command lines to clear out existing rules and set up the default policies

when you have created the file, one step remains which is to set its attributes to allow it to be executable. This is done by typing chmod 755 resetiptables
Finally you can run the script but this needs to be done with system privileges using sudo by typing

sudo ./resetiptables

a bit of an anticlimax as you won’t see anything, all being well

You can check there are no filter changes by typing sudo iptables -L

and no nat rules by typing sudo iptables -t nat -L

now we need to create the rules necessary to set up the forwarding and NAT that we require

the following script will program iptables to do that

#!/bin/sh
 IPT=/sbin/iptables
 LOCAL_IFACE=eth0
 INET_IFACE=wlan0
 INET_ADDRESS=192.168.1.98
# Flush the tables
 $IPT -F INPUT
 $IPT -F OUTPUT
 $IPT -F FORWARD
$IPT -t nat -P PREROUTING ACCEPT
 $IPT -t nat -P POSTROUTING ACCEPT
 $IPT -t nat -P OUTPUT ACCEPT
# Allow forwarding packets:
 $IPT -A FORWARD -p ALL -i $LOCAL_IFACE -o $INET_IFACE -j ACCEPT
 $IPT -A FORWARD -i $INET_IFACE -o $LOCAL_IFACE -m state --state ESTABLISHED,RELATED -j ACCEPT
# Packet masquerading
 #$IPT -t nat -A POSTROUTING -o $LOCAL_IFACE -j MASQUERADE
 $IPT -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_ADDRESS

Again you can type nano setupiptables copy and paste this into the window and save and exit as previously described. You can check that the process has worked by typing
cat setupiptables

as before you must make the script executable by typing chmod 755 setupiptables

then type sudo ./setupiptables to execute it. As before, if it works there should be no visible response. However we can dump the rules stored by iptables using the command sudo iptables-save > dump.txt which saves the files in a file named dump.txt

we can then inspect that text file using the command cat dump.txt which produces something similar to

# Generated by iptables-save v1.4.14 on Fri Jul 19 21:23:10 2013
*mangle
:PREROUTING ACCEPT [696:64118]
:INPUT ACCEPT [656:51596]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [331:40584]
:POSTROUTING ACCEPT [331:40584]
COMMIT
# Completed on Fri Jul 19 21:23:10 2013
# Generated by iptables-save v1.4.14 on Fri Jul 19 21:23:10 2013
*nat
:PREROUTING ACCEPT [45:5986]
:INPUT ACCEPT [35:2292]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o wlan0 -j SNAT --to-source 192.168.1.98
COMMIT
# Completed on Fri Jul 19 21:23:10 2013
# Generated by iptables-save v1.4.14 on Fri Jul 19 21:23:10 2013
*filter
:INPUT ACCEPT [254:19512]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [123:14100]
-A FORWARD -i eth0 -o wlan0 -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Fri Jul 19 21:23:10 2013
# Generated by iptables-save v1.4.14 on Fri Jul 19 21:23:10 2013
*raw
:PREROUTING ACCEPT [6030:609376]
:OUTPUT ACCEPT [2047:267991]
COMMIT

This is actually an important file, saving the rules in an intermediate format understood by iptables, as we can later use the command iptables-restore to load the rules back in after a reboot

we do this by copying the file dump.txt to the /etc/interfaces dirctory, renaming it on the way as iptables, and adding a further line to the interfaces file

type sudo cp dump.txt /etc/network/iptables

then cd /etc/network followed by sudo nano interfaces to place the interfaces file in the nano editor. Move down to the end of the file using the cursor keys. press return for a blank line and add the line

pre-up iptables-restore < /etc/network/iptables

then exit using ctrl+o to write the modified file then push the return key and then type ctrl+x to exit the editor

Check the contents using cat interfaces

we have to tell the kernel program to allow packet forwarding

This is done by editing the file /etc/sysctl.conf

type sudo nano /etc/sysctl.conf

scroll down the file using the down arrow key until you see a line that says
# Uncomment the next line to enable packet forwarding for IPv4
and remove the # at the start of the next line, changing
#net.ipv4.ip_forward=1
to
net.ipv4.ip_forward=1

Then write out the file using ctrl+o followed by return and then ctrl+x to exit the editor

type the command sudo sysctl –system to enable the forwarding and you should see something like the link below. {NB for some reason the two – – in the command above merge to one. The command should have – – system at the end, but no spaces between them}

* Applying /etc/sysctl.conf …
kernel.printk = 3 4 1 3
net.ipv4.ip_forward = 1
vm.swappiness = 1
vm.min_free_kbytes = 8192

showing that ipv4 forwarding is enabled

Stage 5 fixing the routing

We are nearly done, there remains one problem, which stumped me for ages, and which is not mentioned in the original article by Glenn Lockwood

The kernel maintains a routing table that helps it to know where to send packets with different addresses

The contents can be seen with the command route

This produces

Kernel IP routing table
Destination  Gateway      Genmask        Flags Metric Ref Use Iface
default      192.168.2.1  0.0.0.0        UG    0      0   0   eth0
192.168.1.0  *            255.255.255.0  U     0      0   0   wlan0
192.168.2.0  *            255.255.255.0  U     0      0   0   eth0

This shows that any packets addressed to a network apart from 192,168.2.x (which will be routed via eth0 on 192,168,2,1 or 192.168.1.x which will be routed via wlan0 on 192,168,1,98 will by default be routed via the ethernet port on 192.168.2.1
This is not at all what we want. We want packets to unknown networks on the internet to be routed via the wlan0 interface to our network router and from thence to the internet.
In otherwords we want the default gateway to be 192.168.1.1 via wlan0 and NOT 192.168.2.1 via eth0

This is easily achieved with the two commands route del default gw 192.168.2.1 etho to remove the unwanted one and route add default gw 192.168.1.1 wlan0 to add the required one. However the question is when and where to do it. We can only apply these commands once the routing table has been set up, namely once the network interfaces have been configured. There are hooks to invoke commands after an interface has come up, but we don’t what these to happen until both interfaces are active.

The solution I have chosen is to add a script to perform the commands which is placed in the directory /etc/init.d and which is invoked at the end of the booting sequence once the interfaces have been set up.

The script can be created first in the pi home directory

type cd ~/ to get there

then nano setuproutes to edit the new file called setuproutes

paste or type the following into the nano editor window

#!/bin/sh
#/etc/init.d/setuproutes
#
### BEGIN INIT INFO
# Provides: default routes for wlan0
# Required-Start: $syslog $network
# Required-Stop: $syslog
# Should-Start:
# Should-Stop:
# X-Start-Before:
# X-Stop-After:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# X-Interactive: false
# Short-Description: adjust default routes
# Description: removes default route 192.168.2.1 adds default route 192.168.1.1
### END INIT INFO
sudo route del default gw 192.168.2.1 eth0
sudo route add default gw 192.168.1.1 wlan0
exit 0

The line # Required-Start: $syslog $network ensures that the script is not started and run until the system logging and the network interfaces have been set up. The INIT information is required for any init.d script (which normally start and stop computer services to function properly. The actual meat of the script is in the last three lines, exit 0 ensuring that exits cleanly.
Use ctrl+o followed by pushing return to write it, then exit the editor with ctrl+x

set the execution attributes with chmod 755 setuproutes

sudo cp setuproutes /etc/init.d to put a copy in the init.d directory

To activate it to run during the boot sequence type sudo update-rc.d setuproutes defaults

reboot using sudo shutdown -r now then connect to the pi on 192.168.1.98 via ssh again as detailed before. Check that the routing table is now correct using route

You should get

Kernel IP routing table
Destination  Gateway      Genmask        Flags Metric Ref Use Iface
default      192.168.1.1  0.0.0.0        UG    0      0   0   wlan0
192.168.1.0  *            255.255.255.0  U     0      0   0   wlan0
192.168.2.0  *            255.255.255.0  U     0      0   0   eth0

showing that the default route is now correct

As final icing on the cake, we will add a dhcp server so that an IP address can be obtained automatically for the TV or any other computer plugged in to the Rpi ethernet socket. (One other use for the project would be to connect a small network switch with say5 or 6 ports on it to the Rpi to enable several computers to be serviced by the Rpi on their own mini network.)

Type sudo apt-get install isc-dhcp-server and the server package should be downloaded and installed from the internet. (If the package cant be found type sudo apt-get update followed by sudo-apt-get install isc-dhcp-server )
Note when the server is installed you may get an error message saying it can’t be started. This is normal as we have not yet configured it.
The dhcp server configuration file is stored at /etc/dhcp/dhcpd.conf We will keep a copy of this for reference and then substitute it with a new file.

Type sudo mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.orig to make a copy
then create a new blank file using sudo nano /etc/dhcp/dhcpd.conf

paste the following text into the file

#
# Configuration file for ISC dhcpd for Debian
#
#
ddns-update-style none;
option domain-name "rbn.local";
option domain-name-servers 192.168.1.1;
default-lease-time 600;
max-lease-time 7200;
authoritative;
log-facility local7;
#let the server know about network 192.168.1.0 but offer no service here
subnet 192.168.1.0 netmask 255.255.255.0{
}
#configure service for network 192.168.2.0 (the ethernet port)
subnet 192.168.2.0 netmask 255.255.255.0 { 
 range 192.168.2.10 192.168.2.50;
 option routers 192.168.2.1;
}

Then write it using ctrl+o and press return, then exit nano using ctrl+x

Check the contents of the file using cat /etc/dhcp/dhcpd.conf
(If your main home network is NOT on 192.168.1.x you will have to amend some of teh addresses in this file to suit. e.g. if your main router is  on 10.0.0.1)

You can now restart the dhcp server using
sudo service isc-dhcp-server restart
you will probably see the messages

[FAIL] Stopping ISC DHCP server: dhcpd failed!
[ ok ] Starting ISC DHCP server: dhcpd.

The Fail occurs because the server was not running to start with. What you want is the ok for the server starting

Stage 6 Testing and setting up the TV

At long last the project is complete. All that remains is to try it out. You can check its operation with a spare laptop or pc first if you like. Connect the Rpi ethernet socket to the ethernet socket on the laptop or PC and reboot the Rpi. The laptop or PC should be set so that its ethernet adapter will pick up an IP address using dhcp, which will usually be the case by default. All being well you should be able to access the internet from the laptop or PC.

My TV is a Panasonic Viera TX-L37E5B The Menu has an option to gonfigure the network interface. This is set up for a wired connection (to the Rpi!) and set to obtain an IP address automatically (via DHCP). After a short pause the IP address was automatically populated with 192.168.2.11 and I was able to access the various internet options provided by the TV software.

I hope that you have found this article interesting to follow. I have learned a lot in developing it.

Quick install for the impatient

Finally for those who want to try this out quickly, I have saved a zip file containing all the scripts and configuration files used in a file called tvrouter,zip which can be downloaded fromhttp://r.newman.ch/tvrouter.zip The best way to utilise this is get an Rpi setup and working (read stage 1 of the article to see how to do this if necessary) and then to download it to your home directory (assuming the Rpi is connected to the internet) using wget http://r.newman.ch/tvrouter.zip
then type unzip tvrouter.zip
cd tvrouter
ls to see the files
The file README.txt contains the instructions for how to quickly install them
cat README.txt

Image showing the TV picking up its DHCP supplied IP address
tv1e

209 thoughts on “WiFi to ethernet adapter for an ethernet-ready TV

  1. Thanks for an excellent article. I want to use such a bridge to a “single device login” (hotel etc) to a spare router and rebroadcast my own SSID.
    The challenge will be automating the “login credentials” which are normally entered into their redirected login page. (Open network with redirect where no active session). I’m hoping to find that info or work it out.
    Off to purchase my first RPi !!!

  2. Hey I have been trying to do this now for a few days however I cannot seem to get it to work. I am having to use a wpa_supplicant.conf file – as I am currently trying to access my university internet to bridge my connection to my Xbox One.

    I can get my pi to connect to the internet, however whenever I update the /etc/network/interfaces file to have the static eth0 ip information, on the reboot my wifi dongle doesn’t connect to the internet (cannot ping google.com), and therefore as a result when I reach step 5 I cannot download the dhcp server.

    I know this is quite an old thread but would love it if you could help me out.

    Many thanks,

    Josh

  3. This worked very well, I appreciate the thought and effort you put into explaining each section.

    I did run into one error, here:
    “type the command sudo sysctl –system to enable the forwarding and you should see something like”

    I believe it should be sudo sysctl –system two hyphens not just the one. Other than that it worked great, thanks again.

  4. No need for “Stage 5 fixing the routing”, just remove the gateway from eth0 in /etc/network/interfaces, and it will use the gateway defined in the wlan0 interface instead without needing to change routing.

    I did the above using your guide but using a reserved DHCP ip for the wlan0, and it worked.

    • I did however use dnsmasq instead of isc-dhcp-server, as I prefer that. It sets the eth0 DHCP details to use the eth0 ip as the gateway for DHCP clients to connect to.

    • I also found this point, Stage 5 fixing the routing is not stable method, gateway will go back 192.168.1.1. for remove gateway for eth0 is the solution.

  5. hi,
    first nice work.
    but 1 line in wlan0 is missing
    namserver 192.168.1.1
    to resolve the domainnames to ip
    first i tried it with my notebook and works fine but i want to use it with my mediareciver (german telekom) conection is established but it works for about 6 sec and than it hangs wenn i switch to an other program it works for about 6 sec and stops again it dosent matter if it is SD or HD
    i tried to enlarge the swapfile to 2 GB course i thougt that ram is not enought but no it works only for about 6 sec.
    anybody an idea how to get it work and not only for 6 sec

  6. Thanks Robin. works like a charm. learnt a lot from your article.

    Now while my TV has got internet connection, I am unable to use services like miracast, DLNA, wifi remote apps etc offered by TV.

    This is because the TV is on an “internal” network with Rpi, so it doesnt appear to devices connected to the wifi router.

    I am trying to work out if there is anyway to “publish” these services on the wifi, so that devices could connect. if i am able to do that it will entirely eliminate the need for a wifi dongle.

    any thoughts that you may have?

    cheers
    Rachit!

    • Hi Rachit
      I have also looked at this but not managed to get a stable solution. I have tried a range of possibilities and return to it from time to time but have not been successful so far.

      • I believe it’s due to the pi’s routes not being communicated to the wlan0. Whether that’s due to ARP not using IP transport, and so WPA is rejecting the ARP data, or that more configuration is needed on the pi to advertise the routes, I don’t know, but I’ll have a look into it.

      • Sorry, forgot to mention, adding the route manually to a computer on the wlan0 side sorted it out, which is why I figure it being ARP.

        route add -net 192.168.2.0/24 gw 192.168.1.1

    • You could also try the steps I mentioned in my comment of 24th March, which is similar to andytson’s recommendation. Not sure if this will help with the uPnP stuff though :\

  7. great guide, Robin! I used it, adapting a little bit, for my Radxa. And it’s working! You guide is not only usefull to create the bridge, but to understand too the basic concepts behind bridging methodology. Great Robin!

  8. good morning, again me.
    Again my compliments for the guide. Well done.
    The ‘bridge’ is working: i tested with my pc and 3 ethernet devices (1 sat decoder, 2 bluray disk players): it is able to go on internet and receive packets.
    I have a an issue:
    all ethrenet devices (192.168.2.x) are unable to find/use a dlna server I have installed on my modem/router (192.168.1.1).
    why? I did something wrong during setup or it is a common behaviour? and if a common behaviour what is the root cause and howto solve?
    thanks

    • Hi there.
      I think DNLA IS a problem with this set up. It won;t work properly over different networks, but requires all the devices to be on the same network branch. I and others have spent some time trying to find a work around, but to date I am unaware of a working solution to this problem.

      • In any case, Robin, great job!
        I’m not a Linux expert, but I work on IT matter. I will try to do additional test and inform you about outcomes.
        thanks ciao

  9. Hey,

    it works great .. but … how can I access the lan-connected devices per ssh?
    My main network is 192.168.178.1 and my new network is 192.168.179.1. My lan-connected device has the ip 192.168.179.10 but all tries to ping it failed.
    The device can access the internet without problems but I cannot access it directly.

    • Phil
      When I originally wrote this (quite a time ago now!) it was intended to allow my tv to get an internet signal, and it is fine for that. However as you have found out you can’t easily go in the other direction. It is like your internet router. Stuff outside doesn’t know about your machines on the local network. You would have to have a route established from your local network machine so that it knew where the machine on the ethernet port of the pi is located. I am not a guru on such matters, but I hope you can work something out.

      • Hey,

        I think I can do two things.

        1. Port forwarding
        2. SSH tunneling

        Thats a bit more work for every Pi but should be work.

  10. Thanks for the great article and explanation behind the commands. I’ve been trying to replicate this but everytime I connect the ethernet cable the Wifi shuts down. I’ve seen on other pages that removing ifplugd or including eth0 allow-hotplug would solve those issues. However, I have allow-hotplug eth0 and removed ifplugd as well and still everytime I connect the ethernet cable the wifi shuts down. Removing the ethernet cable brings back the wifi so this seems to be an automated process. Also, I have a 2A power supply, some people suggested lack of power which is not the case.

    I’m new to Linux and the raspberry pi so this is a strange behaviour which I can’t seem to pinpoint the cause.

    Any clues on how to manage the automatic disconnection of wifi when ethernet cable is connected?

    Thanks

  11. Thanks for the very interesting tutorial. I’m new to Linux and the Raspberry Pi and this was a good introduction to what it can do.

    However, I have a problem. Whenever I connect the ethernet cable the wifi adapter shuts down. If I subsequently disconnect ethernet, wifi goes back on. It does seem to be an automated process.

    I’ve looked around and people seem to point in three solutions all of which haven’t worked for me: a) stable power – I have a 2A adapter so not an issue; b) allow-hotplug eth0 – I had already included this command in /etc/network/interfaces; c) remove ifplugd – I didn’t have this command installed to begin with.

    I’m running the latest alpha4 OSMC for a raspberry pi 2. As I’m new to the Pi I’m not sure which files I should look at for automated processes. Any ideas on how to keep the wifi connected when ethernet is connected as well? It defeats the purpose of having the TV connected to the internet using an ethernet connection.

    • EDIT: Sam Nazarko helped out. There’s a connection manager file which has specified this as a ‘SinglePreferredTechnology’. In /etc/connman.conf, changed the instruction to ‘false’ and it’s working fine.

      • EDIT2: when rebooting the wifi doesn’t come on. Also, the ethernet IP address does not seem to be static and using the one inputted in /etc/network/interfaces.

    • Sorry that you are having trouble. Not sure why your ethernet address is not static. It should be if you have an interfaces file like
      # The loopback network interface
      auto lo
      iface lo inet loopback
      # the internal (wired) network interface
      allow-hotplug eth0
      iface eth0 inet static
      address 192.168.2.1
      network 192.168.2.0
      netmask 255.255.255.0
      broadcast 192.168.2.255
      gateway 192.168.2.1
      # the external (wifi) interface
      allow-hotplug wlan0
      iface wlan0 inet static
      address 192.168.1.98
      netmask 255.255.255.0
      broadcast 192.168.1.255
      gateway 192.168.1.1
      wpa-ssid “XXXXXXXXXXX” (insert your own values for XXXXXX in these two lines)
      wpa-psk “XXXXXXXXXX”
      wpa-group TKIP CCMP
      wpa-key-mgmt WPA-PSK

      I don’t have the system built at present, but I have configured it several times and have not had the problems you describe. Double check you have done all the steps in the article.

      Generally I would advise against plugging wifi dongles in or out while the Pi is running. I think later models may be OK, but it certainly upset early ones.

      • Thanks for getting back to me. I’ve since managed to sort out my issues.

        OSMC uses connection manager instead of the typical interfaces file in /etc/network and IP tables. They key is to edit the connman.conf file in /etc.

        Opening this file up I’ve changed the following:
        SinglePreferredTechnology=false
        PreferredTechnologies=wifi,ethernet

        This allowed me to keep the wifi on when rebooting. I then created an ethernet.config file in /var/lib/connman to include the following:
        [service_ethernet]
        Type=ethernet
        IPv4=192.168.2.2/255.255.255.0

        This created static IP to the ethernet port.

        However, I don’t think this is really necessary. The way that ConnMan routes traffic from wifi to ethernet is by using tethering, completely different approach to the one in this tutorial.

        Editing the connman.conf file in /etc I included the following lines:

        TetheringTechnologies=wifi,ethernet
        PersistentTetheringMode=true

        I ran the the command ‘connmanctl tether ethernet on’ to turn on the tethering for ethernet and getting internet through it.. On my next reboot the Pi was routing traffic to the ethernet and my TV has internet! Result!

    • Thanks. Mihal. This has been raised before. For some reason the page doesn’t display this correctly. There ARE two – – in the script on the page, but they merge to one. I have now added a note to clarify this.

  12. good info. thanks.
    Has anyone tried a (transparent bridge) setup whereby your TV would ‘dhcp’ (via the wired-to-wireless bridge) direct to your home router?
    That way there would be no need for any ‘static’ address configuration on either the wlan0 or eth0 – e.g. the Rpi would be transparent, and the router would see the TV as just another wireless device. Albeit, you would lose your ssh capability to the pi.
    This would also allow one to place an Ethernet ‘hub’ off of eth0 and connect additional devices that would also ‘dhcp’ (wirelessly via the Rpi).

    • What you describe is exactly the setup I’m looking for.
      Would be great to do this.

      Otherwise, the tutorial works like charm!

      • Fantastic tutorial. I too am looking for a solution to get rid of the IP_ADDRESS static value. I know that from the command line I can do hostname -I and get the IP address that was assigned to my wireless wlan0 (through my iPhone)…but I am fairly certain that iphone does not give me the same IP address each time I connect to the Personal Hotspot. Can I have someone tell me the command that would adjust setupiptables script so that it would be something like:

        INET_ADDRESS=${hostname -I} (I don’t know sh at all!)

  13. Hi – I’m having trouble with the setup of this. On the initial setup of the Pi (using Raspian) I can get online no problem. When I change the interfaces file, I can no longer get online wiith the pi – it doesn’t appear to connect to my router. I have tried both manually following your post line by line and also by downloading your files but neither works! The wpa_gui no longer shows the wlan0 device either. Please help!!!

    • Digging a little further (with my very limited knowledge), when I try to ping anything it shows as pinging from eth0 (192.168.2.1). It’s as if the pi can no longer see wlan0

      • Hi Greg
        Sorry to hear you are having problems. It is not all that clear from what you say how far you have worked through the article, and at what stage you are having problems. At the end of stage 2 did you see two ip addresses listed when you did ip addr, one for the eth0 and the other for the wlan0 interface?
        You mention an eth0 address of 192.168.2.1 so I guess you have progressed beyond that stage, as this is the address I specified in Stage 3 again at the end of that section did you see the two ip addresses on the RPi at the end of the boot process? After you have set up the iptables you have to fix the routing as in Stage 5 before things will start to work. You should end up with a routing table like the SECOND one shown in stage 5.
        I don’t have the project setup at the moment but I will try and run through it again over the next day or so and check it out again. Raspian has moved on a long way since it was originally written! However, many others have successfully completed it. If all else fails, you can restore the interfaces file to its default value again:
        auto lo

        iface lo inet loopback
        iface eth0 inet dhcp
        wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
        ifaace default inet dhcp

        You should also disable the setuproutes script installed in /etc/init.d using sudo update-rc.d setuproutes disable
        Hopefully if you reboot and startx you should be able to use the wpa_gui to connect via WiFi again.

      • A further reply. Greg, I tried out the project on a Pi2 with the latest Raspian distro, and I too had problems with the wlan0 interface. I did some research on teh internet, and came up with a solution that appears to work. Se the amendment published here today Hope it works for you. It is working fine on my Pi2.

  14. Worked for me as well! Thanks for this. Now I am wondering if I want to undo it again. How can I do it the most fastly by using terminal commands?

  15. Nice done!
    To make the iptables config independent of the $INET_ADDRESS use the following config:

    #!/bin/sh
    IPT=/sbin/iptables
    LOCAL_IFACE=eth0
    INET_IFACE=wlan0

    # Flush the tables
    $IPT -F INPUT
    $IPT -F OUTPUT
    $IPT -F FORWARD
    $IPT -t nat -P PREROUTING ACCEPT
    $IPT -t nat -P POSTROUTING ACCEPT
    $IPT -t nat -P OUTPUT ACCEPT
    # Allow forwarding packets:
    $IPT -A FORWARD -p ALL -i $LOCAL_IFACE -o $INET_IFACE -j ACCEPT
    $IPT -A FORWARD -i $INET_IFACE -o $LOCAL_IFACE -m state –state ESTABLISHED,RELATED -j ACCEPT
    # Packet masquerading
    $IPT -t nat -A POSTROUTING -o $INET_IFACE -j MASQUERADE

      • Yes, I confirmed that it works fine with those changes when wlan0 is DHCP.

        Thanks for this great tutorial! With this change and eliminating the Stage 5 stuff (just omit the eth0 gateway statement in /etc/network/interfaces) it’s pretty darn simple

  16. Awesome guide, I’ll be using it to set this up for my own Rpi project. I will add a further complication to the mix in that I want the wlan0 to connect via a VPN service. There seem to be guides for that so hopefully they’ll play nicely with the wireless to wired setup.

  17. thanks loads works a treat on my pi 1 model B+ i get 10 meg download and 1.2 meg upload the pi is upstairs and the router downstairs do you know if it is ok just to turn off at the wall if need be or will it mess it up if not shut down using ssh

  18. Thank you very much for the tutorial – I learned so much from it!

    I used your method to turn a RPI2 into a router and a DHCP and DNS server (using dnsmasq) on my autonomous robotic vehicle. The machines on the LAN behind the PI-router run a distributed robotic system (using ROS) among themselves.

    I have one problem that I am trying to solve: I need to be able to connect to any machine on my robot’s LAN directly from the outside.

    My robot’s LAN is static 192.168.2.1 (eth0) and my wifi (wlan0) is static 192.168.0.200. At the moment, I am unable to ping, say from 192.168.0.13 to a machine on my robot’s LAN (e.g. 192.2.31) and I would like to change this situation.

    I tried hacking setupiptables script, but I have not been successful.

    Could you (or anyone) please give me some pointers/ideas/advice on how I can connect to any machine on my robotics LAN from the outside?

    Thanks in advance

    Galto

    • Correction:

      “At the moment, I am unable to ping, say from 192.168.0.13 to a machine on my robot’s LAN (e.g. 192.168.2.31) and I would like to change this situation.”

  19. your guide is excellent!!!!
    i can see the networks inside the local network.
    i tried a step further by adding in a AP hoping to get the local ips:which each is running nginx, to work when i connect via iphone or equivalent. unfortunately i cant seem to get them. any help in this area would be great…

    i tried looking at this site:
    https://realiesone.wordpress.com/
    which features a headless AP NAT webserver.
    if ONLY i could get the iptables correct….

  20. Thats exactly what i have searching for. Thank you so much.
    My Receiver in my living room has only an ethernet connection.
    Now its over Wlan!!

  21. FANTASTIC that’s all I can say about this. I tried to install it the hard way, following instructions but it failed. I downloaded you .zip file and did ADMENTMENT as step 8A (before installing DHCP) and it ran without problems! Excellent, thank you so much for your work and explanation of how things work.

  22. Let me be the first to say: Congrats, Neil! I’ve been following this site from day one, and have loved every single day of awesomeness that it has delivered. You deserve all the success coming your way. Keep it up!AWESOME!

  23. I used the concept to connect a computer out of range of the wifi to the internet.
    After doing all the steps I had the problem, that the connected computer had no access to DNS, i.e. ping 8.8.8.8 worked, but ping google.com did not.
    So I added

    option domain-name-servers 192.168.1.254, 8.8.8.8;
    # the first address 192.168.1.254 has to be replaced by the address of the local dns-server
    # the second address 8.8.8.8 is the address of google’s public dns

    to dhcpd.conf just after the line

    option routers 192.168.2.1;

    Then everything worked fine.

    Thanks.

  24. Hej there,

    I got a small problem with the resetiptables. When i’m trying to execute the resetiptables script.. i get an error..
    ./resetiptables: 4: ./resetiptables: -P: not found
    ./resetiptables: 5: ./resetiptables: -P: not found
    ./resetiptables: 6: ./resetiptables: -P: not found
    ./resetiptables: 7: ./resetiptables: -t: not found
    ./resetiptables: 8: ./resetiptables: -t: not found
    ./resetiptables: 9: ./resetiptables: -t: not found
    ./resetiptables: 10: ./resetiptables: -t: not found
    ./resetiptables: 11: ./resetiptables: -t: not found
    ./resetiptables: 13: ./resetiptables: -F: not found
    ./resetiptables: 14: ./resetiptables: -X: not found
    ./resetiptables: 15: ./resetiptables: -t: not found
    ./resetiptables: 16: ./resetiptables: -t: not found
    ./resetiptables: 17: ./resetiptables: -t: not found
    ./resetiptables: 18: ./resetiptables: -t: not found

    U know what the problem can be?

    Matthijs.

    iptables is already the newest version.

  25. I assume you are using sudo to run the program.
    sudo ./resetiptables

    Also does
    which iptables
    return a path for iptables? (used in the first line)

    Rather than creating the program yourself have you tried using the downloadable version in my zip file?

  26. I hit that issue
    root@raspberrypi:/proc/sys# sudo sysctl –-system
    sysctl: cannot stat /proc/sys/–-system: No such file or directory

    any suggestion?

    • looking at your post you are using two – – before system? yoru version copied from above is –-system
      typing it here looks differnt –system
      Just tried sudo sysctl –system on my Pi here. No problems

  27. pi@raspberrypi:/etc/network $ sudo sysctl –-system
    sysctl: cannot stat /proc/sys/–-system: Datei oder Verzeichnis nicht gefunden

    comes up here which says “file or folder not found” and yes, I used two dashes. What can I do or am I doing wrong?

  28. Hi, great tutorial.
    There is just one thing I connot figure out how it works. The FORWARD rules of the *filter table are :

    :FORWARD ACCEPT [0:0]
    -A FORWARD -i eth0 -o wlan0 -j ACCEPT
    -A FORWARD -i wlan0 -o eth0 -m state –state RELATED,ESTABLISHED -j ACCEPT

    The FORWARD policy (first line) is ACCEPT. That is, every packet not matching the two following rules will be accepted. Both rules have an ACCEPT target. Finally, *every* packet will be accepted ! So what is the purpose of these two FORWARD rules ? Keeping only the FORWARD ACCEPT policy and adding no FORWARD rules should do exactly the same job.
    Could someone explain me what I missed ?

  29. Hi

    I’ve tried your instructions on a RPI3 including the amended one, and I cannot get it to work. Is it possible for you to please provide an image of your sd card so I can flash it directly onto mine and see if it works? Using e.g. wetransfer as above?

    Thanks again!

    • Hi Rob
      I’m afraid I won’t have access to the image for about a fortnight, but I’ll try and post it then. It is quite an old image, so may need a bit of updating to run on Pi2/3.
      Robin

      • That’s fine. Thanks a lot for your efforts. I have no problems updating the images.

        Also, does your latest image have the fix you mentioned in another post to work with later iterations of raspbian?

      • Hi Rob
        I managed to fit in a few hours in my Pi today, and having looked at the latest Raspbian image it was apparent that the original article (written in 2013) is now wildly out of date, and will not work with the present system. This is because of changes in the distro regarding the way that it likes to set up ip addresses in the ethernet and wireless interfaces. I decided that the only way to sort things was to start again from scratch. After quite a lot of head scratching and trying out various solutions I believe that I now have a working solution for the latest distro. I want to test it a little more, but I intend to write an updated article which I hope will get you and others trying to set up this system going. It will take a little time, (especially as my Daughter is about to have a baby and that will occupy some of my time!) but I hope it will be worth waiting for.

      • Hi,

        Tried the steps, but still unable to get it working on my setup. Is it possible for you to send me a link of your rpi3 image with the working wifi to Ethernet ‘bridging’? I think it might be due to my current configuration on the rpi3, but am not exactly sure. The reason is i’m not linking the wifi to a TV, but camera (similar principles) and the other side to a computer so I can control it remotely.

        If your image works on my rpi3, i’ll know it’s my configurations and figure out how to get it all working. If it still doesn’t work, then i’ll know it’s probably camera related.

        Thanks again

  30. great article. The only problem i have with that setup is the two different subnets. one for eth0 and one for wlan0. is there a way to have both of them in the same subnet so they can see each others IPs?

  31. Hi,
    Thank you for the usefull tutorial. I just have on problem I don’t understand:
    On the stage 4, i successfuly executed ./resetiptables,but when i arrive at ./setupiptables, it gives no result: dump.txt is empty, and there is only one “chain postrouting” when i execute
    sudo iptables -t nat -L.

    After that, everything seems to work (i stopped before installing the dhcp server, just to test it)
    I have a computer on the ethernet side. I tried to do some pings:
    successfully ping the raspberry’s ethernet, wlan, but nothing on the other network. Worked once, but stopped after a reboot

    If you have any idea to help me, it would be greatfully accepted ><
    Thanks!

      • Hi,

        Thank you for your answer.
        I continued to surch during a day or two, and finaly made it work.
        I took here the part about DNS, and the rest…

        I connected the raspberry pi on the wifi with the graphical interface, and the ethernet on manualy (on /etc/network/interfaces). Just added “metric 300” at the end of eth0 configuration. I wanted to try everything, and then forgot it. Don’t know if it changes anything or if that wrong, but i don’t want to remove anything now it’s working. I’ll try it later.

        About the routing table: I think it’s the same as yours. The only gateway is the one on the wlan0, the other one is deleted during the startup.
        (added
        “#Routing
        post-up route del default gw 192.168.1.254” at the end of /etc/network/interfaces)
        For the iptable, I used:
        “sudo iptables -t nat -A POSTROUTING -j MASQUERADE”

        And… I think that’s all. Thank you for your answer and your work anyway, it’s super usefull!
        (Sorry for my English)

      • Spotted another slight typo….

        NB there are two similar files dhcpcd.conf and dhcp.conf Make sure you choose the right one. The former configures the dhcp client daemon, the second configures the isc-dhcp-server daemon. From the nvtr folder you can also copy the iptables file to the etc folder using:

        Should be

        From the nvtr2 folder you can also copy the iptables file to the etc folder using:

  32. I seldom drop responses, but i did a few searching and wound up here WiFi
    to ethernet adapter for an ethernet-ready TV | rbnrpi.
    And I actually do have a couple of questions
    for you if you tend not to mind. Could it be just me or does it appear like some of these remarks come across as
    if they are coming from brain dead visitors? :-P And, if you are writing on other online social sites, I’d like to follow everything fresh you
    have to post. Would you list of all of your social pages like your twitter
    feed, Facebook page or linkedin profile?

  33. Following your guide, I am able to get wired only PC connect to the internet via Pi3 through home wifi router, however, I found that the wired only PC is not on the same subnet as other PCs connected directly to the wifi router.

    Is it possible to connect these two subnets together?

  34. Hi, I’m new to this raspberry pi comunity thing.
    I’ve got some difficulties because my raspi doesn’t like the static ip in the file `interfaces` as soon as i put it inside `dhcpcd.conf` it seems to work.
    But when I tipe “sudo service isc-dhcp-server restart” all i get is :”Job for isc-dhcp-server.service failed because the control process exited with error code.
    See “systemctl status isc-dhcp-server.service” and “journalctl -xe” for details.”.
    Any helps??
    Using Raspberry Pi 3b+ with Raspbian 4.19.34-v7

    • Sorry you are having some difficulties. This is now a very old project, and there may well be difficulties with more modern version of raspbian. I trust you are working with the updated version mentioned in the original article. I’m afraid it is difficult to give you any specific suggestions, especially since I have not looked at this project for several years. I wish you luck in sorting it out.

Leave a reply to dwerg Cancel reply