1

I've read dozens of tutorials and documents on how to configure my Raspberry Pi 3 network properly, but I can't get it to work the way I want. I imagine that the question below is a bit redundant but I couldn't find a suitable solution for my case (or I couldn't totally understand the solutions I did find).

I have the following setup:

Internet <--> Router | <--(WiFi)--> RPi3   (occasionally)
                     | <--(WiFi)--> Laptop (occasionally)
RPi3 <--(wired)--> Laptop (always)

I want to be able to always connect to my RPi3 through the wired connection just because I will be moving both of them to places where the router is not accessible. Besides, I've let the router/DHCP server to automatically provide an IP for my wlan interface and, because there's several joining and leaving the WiFi network I don't always get the same IP. So, in order to check the assigned IP for my RPi every time, I connect to it through the wired interface.

However, I need that whenever the RPi3 is connected to the WiFi network, this becomes the default network (to access the outside world).

That being said, the last important characteristic is that I have my laptop's Ethernet interface set up with static IP 192.168.1.100/24. I need that for other, unrelated, reasons. In order to connect to the RPi3, I decided to also set up a static IP for its eth0 interface within the same subnet than my laptop: 192.168.1.120/24.

Now, what happens is that when the Ethernet connection is available between my RPi and laptop, my RPi is unable to reach the outside world. In particular, it is unable to resolve DNS queries.

This is my /etc/dhcpcd.conf setup, whereas /etc/network/interfaces is left unchanged:

interface eth0
static ip_address=192.168.1.120/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1
  • Router IP: 192.168.0.1
  • Laptop eth0 IP: 192.168.1.100 (static, note different subnet)
  • RPi wlan0 IP: 192.168.0.*** (assigned by the router's DHCP server)
  • RPi eth0 IP: 192.168.1.120 (static)

Using Wireshark I could see that ARP requests from the RPi3 (asking who has 192.168.0.1) are sent to my laptop, which I believe is not correct. Is there a way to solve my network issue just by modifying dhcpcd.conf or I need to define some sort of "bridge" between the two subnets?

Edit: More details:

$ ip -4 addr show dev wlan0 | grep inet
inet 192.168.0.106/24 brd 192.168.0.255 scope global wlan0

$ ip -4 addr show dev eth0 | grep inet
inet 192.168.1.120/24 brd 192.168.1.255 scope global eth0

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG    202    0        0 eth0
0.0.0.0         192.168.0.1     0.0.0.0         UG    303    0        0 wlan0
192.168.0.0     0.0.0.0         255.255.255.0   U     303    0        0 wlan0
192.168.0.1     0.0.0.0         255.255.255.255 UH    202    0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0
  • 2
    I think you mean RPi eth0 IP 192.168.1.120 (static) for your last bullet ? Try removing the routers and domain_name_servers entries from your eth0 interface - then it should only be able to access other machines on the 192.168.1.x subnet and when the WiFi is connected it will route everything else... – KennetRunner Sep 28 '16 at 10:58
  • This has nothing to do with Raspberry Pi. If you want networking to work just leave it alone. If you want to change the way IP routing works get appointed to the appropriate industry forum. – Milliways Sep 28 '16 at 11:13
1

As suggested by @KennetRunner, the solution was simply to remove the routers and domain_name_servers lines from dhcpcd.conf.

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.