I am configuring my Rpi 3 as ethernet router. I have used dnsmasq for configuring dns and dhcp server. The configuration files are given below.


auto lo
iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug eth1
iface eth1 inet static

up iptables-restore < /etc/iptables.ipv4.nat


interface=eth1 #listen only to interface eth1
listen-address= # listen on
# Bind to the interface to make sure we aren't sending things
# elsewhere
server= # Forward DNS requests to Google DNS
domain-needed # Don't forward short names
# Never forward addresses in the non-routed address spaces.
# Assign IP addresses between and with a
# 12 hours lease time


kernel.printk = 3 4 1 3
vm.min_free_kbytes = 8192

At last iptables configuration for seting nat is given below

sudo iptables -F
sudo iptables -t nat -F

#Connect a LAN to the internet
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

#forward only the packets that are associated with an established #connection
sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT

#forward all packets from eth1 to eth0
sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT

sh -c "iptables-save > /etc/iptables.ipv4.nat"

These configuration perfectly works for older wheezy versions and jessie lite version too but in jessie full version( 2017-08-16) its not working.

When i configured the files above, rpi won't get connected to my external router (router and rpi are connected through a lan cable). I think this is because configuration for eth0 is changed when i configured the files as above.

In Raspbian jessie version, i don't know where to configure the network interfaces. Also they shipped with inbuilt bind9 and dhcpcd, hence is there any conflict with dnsmasq server.

sudo service dnsmasq status throws an exit-code error.

Can anyone please help me to solve this?

How to configure Rpi 3 with raspbian jessie for the ethernet router?

3 Answers 3


I think i've read somewhere that you should not modify /etc/network/interfaces anymore.

If you want to set up static IP's you should modify /etc/dhcpcd.conf

interface eth1
static ip_address

Run sudo nano /etc/rc.local And before exit 0; paste:

iptables-restore < /etc/iptables.ipv4.nat

It works for me on Stretch and I've been following raspberrypi.org tutorial and using dhcpcd method ( SUPER IMPORTANT FOR Stretch VERSION )

That's my guess. Provide the error message you get.


In etc/network/interfaces, you don't bring up eth0 automatically -

auto lo iface lo inet loopback iface eth0 inet dhcp

Add in auto eth0 to make sure that eth0 will actually come up and get an IP address, so it should look like this -

auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp

Also the same with eth1, make sure you bring that up automatically.

Raspbian Stretch uses dhcpcd.conf to configure the networking unless they are configured in /etc/network/interfaces

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.