1

I have an Ethernet cable which I use to connect to the internet on a desktop Windows machine.

These are the IP settings I gave the Windows machine:

IP adr.        172.18.14.19
subnet mask    255.255.0.0
gateway        172.18.0.1
preferred DNS 172.18.10.99
alternate DNS 172.31.0.5

Now I am connecting the same Ethernet cable to the Raspberry Pi 3.

I have used:

sudo ifconfig eth0 172.18.14.19 netmask 255.255.0.0 up
sudo route add default gw 172.18.0.1 eth0

in the terminal.

Then I am not able to use the internet. With the same cable I am able to access the internet on desktop. Why is this not the case for the Pi 3?

How do I proceed?

3
  • 1
    Can't you use DHCP? That should work out of the box. For static addresses on Raspbian Stretch you should use /etc/dhcpcd.conf. Examples are at the end of that file. And do not modify /etc/network/interfaces.
    – Dirk
    Commented Feb 21, 2019 at 10:01
  • It's possible that your network uses access control.
    – RalfFriedl
    Commented Feb 21, 2019 at 17:45
  • Does one of the answers help you? If so it would be nice if you could accept one.
    – Ingo
    Commented Apr 10, 2019 at 16:54

2 Answers 2

1

The ethernet cable has two ends. I assume one end is plugged into a port of your internet router and the other end one time to the desktop machine and the other time to the RasPi.

First of all you should not use the same ip address for the desktop device and for the RasPi. In this case it does not conflict direct because the devices are not connected at the same time but it may confuse the router because it often caches connection parameter.

For your desktop machine you have defined DNS server to use. This isn't the case for the RasPi. You should do it. But if you use a default Raspbian installation this is done in /etc/dhcpcd.conf. Don't do manual settings with ifconfig or ip addr add or within /etc/resolv.conf because this will be overwritten by dhcpcd.

Just edit /etc/dhcpcd.conf and append this entries (you will find some examples there):

static ip_address=172.18.14.20/16
static routers=172.18.0.1
static domain_name_servers=172.18.10.99 172.31.0.5

Then restart dhcpcd with:

rpi ~$ sudo systemctl daemon-reload
rpi ~$ sudo systemctl restart dhcpcd.service

Then it should do.

0

Since you haven't added DNS settings to your Raspberry Pi 3 you are unlikely able to surf the web since you have to use IP adr and cant use URL.

Add your DNS server to the file /etc/resolv.conf

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.