0

A friend set up my Raspberry Pi so that it creates its own wireless network and I can connect to it through SSH over the air. The /etc/network/interfaces file looks like this:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255

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

It's great. The Pi hosts its own wifi network, I can join the network from my laptop and connect to the Pi through ssh [email protected].

But now I need the Pi to access the internet. I connect it to my router with an ethernet cable but it doesn't really work. I can ping 8.8.8.8 and get a response. But ping google.com fails. So there is a DNS problem.

I tried

  • adding nameserver 8.8.8.8 at the end of /etc/network/interfaces
  • adding allow-hotplug eth0 before iface eth0 inet dhcp

both of which didn't help.

I looked at the router configuration but didn't quite know what to look for. See screenshots below. One thing I noticed is that the Pi's wlan0 ip is static and set to 192.168.1.1 which is the same address that the router claims for itself (?). But then I thought: Hey, that's a wifi issue and should have nothing to do with my current LAN problem. Correct? Any ideas? Router config 1 Router config 2

This is the content of /etc/iptables.ipv4.nat:

# Generated by iptables-save v1.4.14 on Mon Aug 11 15:58:35 2014
*nat
:PREROUTING ACCEPT [32:5915]
:INPUT ACCEPT [30:4763]
:OUTPUT ACCEPT [3:226]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT
# Completed on Mon Aug 11 15:58:35 2014
# Generated by iptables-save v1.4.14 on Mon Aug 11 15:58:35 2014
*filter
:INPUT ACCEPT [214:21125]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [111:13809]
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
COMMIT
# Completed on Mon Aug 11 15:58:35 2014

1 Answer 1

0

Incorrect. IP address conflict is the key here. Provide another subnet for your WiFi network or (probably better) bridge WiFi AP interface with the ethernet.

iptables may also be blocking some traffic. Please provide /etc/iptables.ipv4.nat contents.

[ignore this paragraph if you go for bridging as advised] You may also be missing a DNS proxy software on your R.Pi. dnsmasq is a nice choice, as it provides both DNS and DHCP service with reasonable defaults for a small router.

8
  • "Provide another subnet for your WiFi network or bridge WiFi AP interface with the ethernet." Can you expplain what both options mean exactly?
    – bootsmaat
    Commented Jul 23, 2015 at 0:16
  • I added the content of /etc/iptables.ipv4.nat above.
    – bootsmaat
    Commented Jul 23, 2015 at 0:25
  • @bootsmaat: He means that you cannot use the 192.168.1.0/24 subnet for both eth0 and wlan0. You need to choose two different subnets for each interface (for example, 192.168.1.0/24 and 192.168.2.0/24). Note that anything in 192.168.0.0/16 can be used for private IP addressing (along with 10.0.0.0/8 and 172.16.0.0/12, but that's usually used for larger networks). Commented Jul 23, 2015 at 1:07
  • @bootsmaat And the reasons for bridging - why to route/NAT your traffic twice? This can cause problems with port forwarding (if your router supports uPNP, it'll be unusable). If you bridge wlan0 with eth0, you will be able to connect directly to your eth. subnet from WiFi - no need for firewall, DNS, DHCP on R.Pi. - all this will be configured on the router. On Debian bridging can be configured directly from /etc/network/interfaces, see man 5 bridge-utils-interfaces. And if you want to separate your networks (cable from wireless) , consider VLANs and different firewall zones on router. Commented Jul 23, 2015 at 4:56
  • @saiarcot895 What lines do I change exactly to achieve this?
    – bootsmaat
    Commented Jul 23, 2015 at 9:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .