I have developed a wifi to ethernet router. Wifi is connected to my home router having internet and ethernet is connected to my laptop( just for testing).My laptop is not getting internet, but it gets an IP address. Following are the configurations.

/etc/dhcpcd.conf :

# 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 eth0
static ip_address=
static routers=
static domain_name_servers=

/etc/network/interfaces :

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

# Please note that this file is written to be used with dhcpcd
# For static IP, 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

/etc/dnsmasq.conf :


# 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


/etc/sysctl.conf :

kernel.printk = 3 4 1 3

vm.min_free_kbytes = 8192

/etc/wpa_supplicant/wpa_supplicant.conf :

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


NAT rules :

iptables -F
iptables -t nat -F

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

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

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

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

/etc/rc.local :

#!/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.
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"

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

exit 0

I disconnected the laptop and checked that whether the Rpi get internet. It is observed that Rpi get internet when laptop is not connected. When laptop is connected Raspberry Pi lost the internet connection.

I can't understand what is the mistake in configuration. I have done NAT, enable IP forwarding, working dnsmasq.

But I got one solution that changing the line iface wlan0 inet manual to iface wlan0 inet dhcp solve this problem.

So anyone can explain what is the difference in manual and dhcp?


You are asking what is the difference between the methods manual and dhcp used to configure an interface in /etc/network/interfaces. In man interfaces you will find:

The manual Method
This method may be used to define interfaces for which no configuration is done by default. Such interfaces can be configured manually by means of up and down commands or /etc/network/if-*.d scripts.
The dhcp Method
This method may be used to obtain an address via DHCP with any of the tools: dhclient, pump, udhcpc, dhcpcd. (They have been listed in their order of precedence.) If you have a complicated DHCP setup you should note that some of these clients use their own configuration files and do not obtain their configuration information via ifup.

So far to answer your question. But let me give some additional remarks.

Please take note that using /etc/rc.local has limitations due to Compatibility with SysV. We have seen many problems here on this site using it. Following the recommendation of the developers from systemd you should avoid using it. /etc/rc.local will run but from the definition of the SysV init system (the predecessor of systemd) it is the last script that runs after boot up. This isn't guaranteed on systemd anymore so it may be possible that it runs to early to meat all conditions it needs.

There should be taken some attention using /etc/network/interfaces together with /etc/dhcpcd.conf. You can find some important information at Differences between /etc/dhcpcd.conf and /etc/network/interfaces?. That answer is from Jan 16 '16 at 5:37, Raspbian Stretch was released 2017-08-16, so it should fit to Raspbian Jessie you still using.

You should consider to upgrade to Raspbian Stretch to be more up to date with networking. I prefer to use systemd-networkd. I haven't used Raspbian Jessie since years so I cannot help you much with it. To get an idea how to make a RasPi a router with Raspbian Stretch using systemd-networkd you can look at Pi Zero-W Networking between modem and router.

  • Instead of rc.local, what can we use here? Is that ok to write in /etc/network/interfaces file. From the link you given, rc.local has less chance to execute, isn't it? – vishnu m c Mar 14 at 6:56
  • @vishnumc I have updated my answer. You can look at the reviisions. As written I'm positive to use systemd. You should use a systemd unit file instead of rc.local to make a clean service with dependencies. There are many examples in the cloud. I can help you with it but not on Jessie. – Ingo Mar 14 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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