Cyroq
Posts: 58
Joined: Sat Dec 14, 2013 2:40 pm

Internet on wifi, not on ethernet

Thu Feb 14, 2019 12:52 pm

Hi all,

I've been browsing and experimenting for hours but I can't find the solution to my problem. I'm running a Raspberry Pi 3 with Raspbian 9 (Stretch). The IP address should be static. With wifi I am connected to the internet, but as soon as I plug in my ethernet cable, the connection is lost. I can still reach the device locally.

This is my dhcpcd.conf:

Code: Select all

# 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.
hostname

# Use the hardware address of the interface for the Client ID.
clientid

# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC43$# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid
# Persist interface configuration when dhcpcd exits.
persistent

# 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. This is applied to DHCP routes.
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

# Example static IP configuration:

interface eth0
static ip_address=192.168.2.55/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.2.254
static domain_name_servers=192.168.2.254

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1
# fallback to static profile on eth0
#interface eth0
#fallback static_eth0
And this is route -n:

Code: Select all

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.2.254   0.0.0.0         UG    202    0        0 eth0
0.0.0.0         192.168.2.254   0.0.0.0         UG    303    0        0 wlan0
192.168.2.0     0.0.0.0         255.255.255.0   U     202    0        0 eth0
192.168.2.0     0.0.0.0         255.255.255.0   U     303    0        0 wlan0
Since many old threads refer to /etc/network/interfaces, which does nothing on Stretch according to this site, I'm kinda stuck. I assume it has to do something with DNS, because I did manage to get an internet connection via ethernet by adding 8.8.8.8 to resolv.conf, but that file is reset every boot.
Many thanks in advance!

pcmanbob
Posts: 9464
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Internet on wifi, not on ethernet

Thu Feb 14, 2019 1:55 pm

The fact you can get an internet connection if you add 8.8.8.8 as a DNS suggests that your router is not offering a DNS at that address you selected (192.168.2.254).

you need to look at your router setup to see which address the DNS is located on.

A simple work round would be to change your static domain_name_servers entry in dhcpcd.conf to this

Code: Select all

static domain_name_servers=192.168.2.254 8.8.8.8
until you find the correct address for your DNS on your router.

edit.

one way to find what setting you are using for the DNS ( assuming wifi/LAN connection are on the same router ) is while just connected to wifi with working internet connection type this at a command line

Code: Select all

cat /etc/resolv.conf
it should tell you what setting is being used when using wifi
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Cyroq
Posts: 58
Joined: Sat Dec 14, 2013 2:40 pm

Re: Internet on wifi, not on ethernet

Thu Feb 14, 2019 3:46 pm

Thanks for your reply. I looks like dhcpcd.conf is the same whether I'm connected by wifi or LAN:

Code: Select all

# Generated by resolvconf
domain home
nameserver 192.168.2.254
I added 8.8.8.8 to 'static domain_name_servers' but it didn't make a difference. In fact, I can't seem to reproduce my previous solution so maybe it's not a DNS issue after all.

pcmanbob
Posts: 9464
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Internet on wifi, not on ethernet

Thu Feb 14, 2019 3:54 pm

OK lets go back to basics

edit dhcpcd.conf and put "#" as first character on all the lines you changed/added. and save the file

then plug in the LAN cable and reboot your pi

you should find you have 2 network connections one wifi one cabled LAN

you can check by running these commands ( might be a good idea to post the results anyway)

Code: Select all

ifconfig

cat /etc/resolv.conf
once you are sure both are connected disconnect the wifi and see if you still have an internet connection.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Cyroq
Posts: 58
Joined: Sat Dec 14, 2013 2:40 pm

Re: Internet on wifi, not on ethernet

Thu Feb 14, 2019 4:05 pm

Alright, I commented all information about the static ip:

Code: Select all

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.2.55/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.2.254
#static domain_name_servers=192.168.2.254
Now the Pi boots with a different ip address (192.168.2.75) but I do have internet access! :)
Next step: how do I set the ip address back to 192.168.2.55 correctly? (I'd like this address because of several other devices linking to this device)

pcmanbob
Posts: 9464
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Internet on wifi, not on ethernet

Thu Feb 14, 2019 4:13 pm

OK it would have been nice to have seen the output of the 2 commands I suggested you run , but hay :(

So if you router is giving you pi an address we know the pi is connecting to the router that's why you have a new IP because the router is now giving IP address to the pi.

So if you don't have internet access then the problem is in your router, probably caused by your attempts to set a static IP, so first option is to power every thing off pi, router and any other PC's connected to the router.

after waiting 60 seconds power the router back on and allow it time to complete its boot cycle before powering the pi and PC's back on.

then check to see if your pi has internet access using a cabled LAN connection.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Cyroq
Posts: 58
Joined: Sat Dec 14, 2013 2:40 pm

Re: Internet on wifi, not on ethernet

Thu Feb 14, 2019 4:25 pm

I'm sorry! The output was this:

Code: Select all

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.75  netmask 255.255.255.0  broadcast 192.168.2.255
        ether b8:27:eb:80:3e:de  txqueuelen 1000  (Ethernet)
        RX packets 7581  bytes 983848 (960.7 KiB)
        RX errors 0  dropped 1  overruns 0  frame 0
        TX packets 7614  bytes 753791 (736.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 233  bytes 19675 (19.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 233  bytes 19675 (19.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.25  netmask 255.255.255.0  broadcast 192.168.2.255
        ether b8:27:eb:d5:6b:8b  txqueuelen 1000  (Ethernet)
        RX packets 472  bytes 80953 (79.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 98  bytes 15886 (15.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        
pi@raspberrypi:~ $ cat /etc/resolv.conf
# Generated by resolvconf
domain home
nameserver 192.168.2.254

Maybe I don't understand you correctly, but I DO have internet connection with the new address! The only thing is that I really like to have the old address back. But I'm not sure what the best/safest strategy is to do this. Should I just go back to my old settings of dhcpcd.conf and try your method of disconnecting everything?

pcmanbob
Posts: 9464
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Internet on wifi, not on ethernet

Thu Feb 14, 2019 4:36 pm

OK if you have internet access using just the cable connection , with wifi disconnected then you don't need to power off your router.

So if you want to set a static IP directly on your pi then you need to choose an address which is out side of the address range assigned by the DHCP in your router.

The safe and possibly easier option is you look and see if your router will assign persistent IP addressing that way the pi can be left as it is and the router will always give it the same IP address.

Now you might not be able to use the address you want (192.168.2.55) if the router has already assigned it to another device, you should be able to see a list of connected devices if you log in to the router setup web page.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Cyroq
Posts: 58
Joined: Sat Dec 14, 2013 2:40 pm

Re: Internet on wifi, not on ethernet

Thu Feb 14, 2019 4:56 pm

Since my provider/router tends to shuffle my ip address once in a while, I rather have a static address. So I shortened the DHCP range and chose a static address outside of that range. Which works! Apparently that specific address (.55) wasn't handled correctly by my router.

Many many thanks for your help and patience! Now I can continue my quest for setting up port forwarding :D

Return to “Troubleshooting”