WiFi to ethernet adapter for an ethernet-ready TV NEW VERSION


This article supersedes the original article here AND the follow up here and should be used for all new installations using the latest Raspbian images released on 2016-09-23

Further updates made on 2nd Jan 2017 to make starting of isc-dhcp-server more reliable. This uses a changed rc.local file and dispenses with the iscserver.service file
Changes are shown in green I have tested this configuration on a Raspberry Pi 3 with the latest Raspbian “Pixel” distribution.

One of the first articles I wrote on this blog was to detail a wifi to ethernet adapter which I made for my TV set. It turned out to be one of the most popular projects I have written about. However it is now well out of date, and with changes made to the latest Raspbian images it will no longer work properly.

I decided to bring it up to date. This new version was developed on the latest Raspbian Jessie light version dated 2016-09-23. If you want, it could also be installed on the full “Pixel” version of the same date, although if you are using it on a dedicated Pi then the light version is probably better.

Much of the original article still applies, The main differences are in the way that the newer distro handles internet connections. These are now based around a dhcpcd – dhcp client daemon –  and its configuration file /etc/dhcpcd.conf Details of the networks are added here rather than as formerly in /etc/network/interfaces. This latter file should be left in its default state copied below:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpd
# For static IO, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
Source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback
iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

You can download and list the configuration files used in the new version of the project to your Pi home folder using

cd ~
wget http://r.newman.ch/rpi/ntvr2.zip
unzip ntvr2.zip
cd ntvr2
cat contents.txt

Backup your existing dhcpcd.conf file using

sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.original

The /etc/dhcpcd.conf file should be edited to read:

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.

# Use the hardware address of the interface for the Client ID.
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.

# Persist interface configuration when dhcpcd exits.

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

interface wlan0
static ip_address=
static routers=
static domain_name_servers=

#following lines are added added
interface eth0
static ip_address=
static routers=

This details the static settings for the two interfaces required: for the ethernet interface, which will also have a dhcp server set up to run on it, and for the wireless interface wlan0 which will connect to your existing wireless hub on your main network. The edited version is in the downloaded ntvr2 folder, and you can copy it from there if you don’t want to do the editing explicitly, using

sudo cp dhcpcd.conf /etc/dhcpcd.conf

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 nvtr2 folder you can also copy the iptables file to the etc folder using:

sudo cp iptables /etc/iptables

or you can create your own as detailed in the original article using the resetiptables, and setupiptables scripts, and then using

sudo iptables-save > /etc/iptables

to create the file in the correct location. The iptables is now loaded for use from the script rc.local at boot time. Save the original rc.local file by typing

sudo cp /etc/rc.local /etc/rc.local.original

Then insert the new rc.local file by typing

sudo cp rc.local /etc/rc.local

The new file looks like this:

#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# insert function definition to start dhcp server
sleep 10 #should be sufficient. You may need to increase
systemctl start isc-dhcp-server
iptables-restore < /etc/iptables
startdhcp & #initiate starting the dhcp server. will occur 10 secs after boot
exit 0

It has one line added, iptables-restore < /etc/iptables as the third last line, and includes a function startdhcp to give a delayed start of the isc-dhcp-server, which is called with startdhcp & so that the rc.local script can exit without delay. When you boot the pi, the dhcp generated eth0 ip address of the connected TV or laptop may come up almost immediately, but will then disappear and reappear after about 10 seconds. This is the only reliable method I have come up with that works, despite readling a large number of posts on teh subject, with many and varied offered “solutions”

Backup your existing sysctl.conf file using

sudo cp /etc/sysctl.conf /etc/sysctl.conf.original

Uncomment the line that enables ip4 forwarding in the sysctl.conf file by using the nano editor

sudo nano /etc/sysctl.conf

and scroll down to the lines

# Uncomment the next line to enable packet forwarding for IPv4

and remove the # before the second line giving:

# Uncomment the next line to enable packet forwarding for IPv4

Then save the file by typing ctrl+X then Y then press the Return key.
Activate the changed file using

sudo sysctl --system

NB note the two – – in the above command before system.
There is now no need for the setup routes script as the routing table sets up correctly.
Install the dhcp server by typing

sudo apt-get install isc-dhcp-server

Backup the original dhcpd.conf file by typing

sudo cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.original

Install the new dhcpd.conf file by typing

sudo cp dhcpd.conf /etc/dhcp/dhcpd.conf

The next section is dispensed with in favour of a simpler if slightly more kludgy change to the rc.local file

Ignore the following text in green entirely. It is retained just to show what has been removed!

Install a new service file to restart the dhcp server at the end of the booting process after all network interfaces are fully established

sudo cp iscserver.service /lib/systemd/system/iscserver.service

Enable this new service by typing

sudo systemctl enable iscserver.service

The contents of the iscserver.service file are:

description=restart isc-dhcp-server

ExecStart=/bin/systemctl restart isc-dhcp-server


Install a suitable wpa_supplicant.conf file to suit your router wireless settings.
This is best done by making a backup of your existing file by typing

sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf.original
and then editing the file by typing
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

and changing the contents to

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


substituting your own network details for the ssid and psk
Use ctrl-X followed by Y and pressing the return key to exit, saving the modified file.

Two final changes to make, using the raspi-config file.

 sudo raspi-config

You get an onscreen menu, which you can navigate with the arrow and tab keys, selecting options with the teturn key
Select number 3 from the on-screen menu (Boot Options) and set the pi to boot
to one of the two Console settings, depending on whether you want an automatic login or not.
Select number 4 and choose the option to wait for anetwork connection to be established.
You can then exit the program. You can select the option to reboot if you wish as that is the next step we require, but plug in your TV or laptop ethernet before doing so, or the ethernet socket may not initialise

Hopefully now everything should be ready to go. Plug in your TV or a laptop ethernet connection set to dhcp and reboot your Pi.  Your tv or laptop should pick up an address (probably from the Pi dhcp server, and all being well be able to communicate with the internet via your main network.

Tests on the Pi include:


ip address

This should list the eth0 and wlan0 interface info showing and respectively


should list the routing table in the form

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         BThomehub.home         UG    303    0        0 wlan0     *        U     303    0        0 wlan0     *        U     202    0        0 eth0

You will have a different entry to BThomehub.home depending on your Wireless Router eg perhaps Brightbox.ee for an EE router, but the rest should be the same.

Check the iptables routing using

sudo iptables -L

which should give

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 


sudo iptables -t nat -L

which should give

target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

target     prot opt source               destination         
SNAT       all  --  anywhere             anywhere             to:

If you have problems in getting the correct wlan0 address that you have specified, eg if you get a different address on the same network like then it may be that the router is not picking op the call for a static address and is serving a different address. You can specify a reserved address of for your Pi using the hardware address of the interface. This is probably a good idea anyway, to ensure that your router dhcp server does not allocate the address to a different device leading to potential problems.

If you find that the isc-dhcp server has not allocated an address to the TV or other device pluggd into your Pi ethernet port then first try rebooting the Pi, and if it still doesn’t work, try restariting the isc-dhcp-server by typing

sudo systemctl restart isc-dhcp-server

This is the reason I added the restart iscserver.service as I found that sometimes the dhcp server had not properly connected with the ethernet interface, and asking it to restart at the end of the booting process made this much more reliable.

Finally you do NOT require the extra script which was added to the first version of this project, detailed in the article here

I have run this new version of the project reliably on my Pi3 for the past week, using Raspbian Lite. In teh days ahead I hope to try it with other version of the Pi. I think it should work with some earlier raspbian systems (after the change to systemd configuration was introduced in early 2015), but I haven’t tested this yet.

Please note that as this project is essentially a router connecting an ethernet wired network to a wifi network, it does NOT allow use of DNLA to interconnect media products, Just as this doesn’t work for devices outside your main local network on the internet connecting to your local devices. DNLA connects devices on the SAME local network.

ntvr2.zip download contains files (amended) used in this article.