0

I have set up my Pi recently. I have found the local IP address for the device so that I can ssh to it. It is connected to the internet by an ethernet cable.

My question is: will this local IP address change at some point? If so, how can I get around this? I don't have a monitor / mouse / keyboard at home, and so I rely on being able to ssh into my Pi.

Do I need to set my Pi to have a static address? Does it remain static even though presumably, the IP of my building's internet will still change.

2
  • 1
    Take a look here. You could also use ssh [email protected] where raspberrypi is the hostname of your RPI.
    – jake
    Feb 2, 2019 at 14:34
  • how is the RPi connected to the internet? ...... it is also unclear why you are concerned about the building's internet IP ( also unclear what that means)
    – jsotola
    Feb 3, 2019 at 20:51

1 Answer 1

1

It is not very likely (but possible) that your pi's ip address will change, because the pi will always ask the dhcp server (most likely your router) for the same ip address. Ingo pointed out how that works: https://raspberrypi.stackexchange.com/a/92747/92303.

As Ingo clarified in the comments there may be also a link-local address for your pi provided by the dhcp server. (avahi only works if your computer is connected directly to your pi.)

To be sure, that your pi will always get the same ip address, the easiest way is to configure your router to always give it to it.

EDIT:

If all that doesn't work well for you, I would suggest configuring your dhcpcd like this: https://raspberrypi.stackexchange.com/a/43189/92303.

4
  • Thanks. I checked my hostname using 'sudo nano /etc/hostname', and it is raspberrypi. By when I try 'ssh [email protected]', it says 'ssh: Could not resolve hostname raspberrypi.local: Name or service not known' Feb 2, 2019 at 15:02
  • I also can't configure the router, as I am just using the apartment building's internet. Feb 2, 2019 at 15:03
  • 1
    @user1551817 In the first step I would trust the DHCP server. link-local addresses configured by avahi and addressable with raspberrypi.local only works if there is no DHCP server. A DHCP server has precedence. Does the network has a DNS name, e.g. apartment.mycompany.com? Maybe you can address the RasPi with raspberrypi.apartment.mycompany.com? You may ask the network manager how DNS name resolution works on his network. Then you have never to bother about ip addresses.
    – Ingo
    Feb 2, 2019 at 19:58
  • @Ingo I was mistaken then and will correct this. (In my network the router is a pi and so avahi does the link-local addresses.)
    – jake
    Feb 3, 2019 at 18:36

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.