0

I am totally confused with setting up Internet connection for my PI 3. My router is setup for static IP distribution. So, all the ip addresses are fixed for each and every devices on my Network including my PI. The usual way I setup Internet Connection for my PI 3 is as follows.

File: /etc/network/interfaces

auto eth0
iface eth0 inet static
static ip_address=192.168.1.3
static routers=192.168.1.1
static domain_name_servers=192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.1

That always worked for me on PI 2. PI 2 would immediately connect to the Internet and it would save that settings forever and ever. However, on PI 3. Those settings are hit or miss. Sometime it makes the connection and other times it wouldn't or even save the settings. So, I went searching for answers on this forum and came across this question ( LAN on RPi2 not working ). I followed the chosen answer. It looks like I am able to get my PI 3 to connect to the Internet using the first step listed there. However, /etc/resolv.conf seems to be changing all on its own. Sometimes it says nameserver 192.168.1.70 on reboot and other times it says domain name nameserver 192.168.1.1 When I do finally manage to get my PI 3 to connect to the Internet, it looses all the settings on Reboot. This doesn't make sense to me. I am running Raspbian Jessie. Could someone please give me guidance?

  • Did you ever try not editing anything and just plug in the Ethernet cord? I've never had to configure anything special when using Ethernet on my pis – ElefantPhace Feb 14 '17 at 19:09
  • @ElefantPhace Is your network setup for DHCP ip distribution? If so, what you say will work and you don't have to do anything. All you have to do is just simply as you said plug the cat5 cable. Done. What I am trying to do is setup my pi for STATIC IP address, which is forever FIXED. It will never change unless I change it, whereas with dhcp everytime you reboot or turn on your PI its IP address could be different. – ThN Feb 14 '17 at 19:33
  • Yes, and in most cases you control that with your router. You're router doesn't care what static IP you've assigned on your device, and in some cases will ignore it. All of my devices have statically assigned addresses, and they're all handled by the router. – ElefantPhace Feb 14 '17 at 22:41
  • @ElefantPhace, sure, but I handle my IP addresses at the device level. Before you you make dickheaded comments, try understanding that your way isn't the only way. – user42000 Feb 15 '17 at 20:07
1

you can do that from /etc/dhcpcd.conf file. Just add those line to the end of dhcpcd config file

/etc/dhcpcd.conf
interface eth0
static ip_address=192.168.1.3/24    
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8

and edit file /etc/network/interfaces by removing all line you added and add this only.

iface eth0 net manual

Then issue:

sudo ifdown eth0
sudo ifup eth0
sudo service dhcpcd restart

Note: If DHCP server enabled on your router, it is recommended that this IP not to be in DHCP range of your router. Otherwise, this IP could be taken by other device.

| improve this answer | |
  • 1
    See, OP is trying to do things the old way. I was doing that too until I came across the new way. I didn't know things changed and couldn't figure out why I was having issues. It might be worth noting that using /etc/dhcpcd.conf is supported in Jessie while /etc/network/interfaces was used prior to Jessie. – user42000 Feb 15 '17 at 20:09
  • 1
    The other way around is to add denyinterfaces eth0 in /etc/dhcpcd.conf. This will tell dhcpcd to do not try anything on eth0 interface. Then you can use the old way like above. – Mero Feb 16 '17 at 12:49
  • @Mero I was just setting up another PI and I noticed something and thought I should try it first before I try Mero's working answer. Well, it worked. My original attempt did not work, because I didn't put /24 after my static ip_address=192.168.1.3/24 in the interfaces file. Once I did that and rebooted, my pi immediately connected to the Internet. Thanks Mero and others. – ThN May 24 '17 at 15:29
0

Is the router assigning fixed IP addresses via a DHCP list you created on the router? In which case, the IP address is being fixed by the router, not by your Pi.

Perhaps this line ...

iface eth0 inet static

... should be

iface eth0 inet dhcp

(and no need for lines with static ip_address etc)

| improve this answer | |

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.