sandy1
Posts: 4
Joined: Sat Jul 13, 2019 3:51 pm

How to set up a static IP using Raspbian Buster

Sun Jul 14, 2019 2:51 pm

Hi,

I am very new to all this raspberry pi server stuff. I am trying to set up a static IP. All of the tutorials I have followed are written for Jessie, and don't seem to work with buster. Can someone explain to me how to do it?

epoch1970
Posts: 3572
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to set up a static IP using Raspbian Buster

Sun Jul 14, 2019 4:58 pm

"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

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

Re: How to set up a static IP using Raspbian Buster

Sun Jul 14, 2019 5:29 pm

Hi.

Since Raspbian Jessie setting a static IP on your pi has remained the same for both stretch and buster.

you just need to edit the file dhcpcd.conf with the command

Code: Select all

sudo nano /etc/dhcpcd.conf
in there you will find an example for setting a static IP, here is a copy from one of my pis

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 RFC4361.
# 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
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private

# static IP configuration:
interface eth0
static ip_address=192.168.1.14/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.251 

# 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
which has a static IP set.

You do need to understand your network addressing and know what your routers IP and DNS server IP's as well, before you can set a static IP.
Your static Ip should also be out side of the address range that your DHCP server in your can assign or you will end up with address conflicts.

The safer and often simpler option is to use reserved IP addressing in your router if it supports it.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

sandy1
Posts: 4
Joined: Sat Jul 13, 2019 3:51 pm

Re: How to set up a static IP using Raspbian Buster

Mon Jul 15, 2019 3:09 pm

Hi. Thank you for your reply. I tried following those instructions, but with no avail. It did not work. And on top of no static IP, Apache2 stopped working and

Code: Select all

sudo ifconfig
no longer showed an address. Any ideas?

epoch1970
Posts: 3572
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to set up a static IP using Raspbian Buster

Mon Jul 15, 2019 3:20 pm

No idea. Post your config files, that should help.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

sandy1
Posts: 4
Joined: Sat Jul 13, 2019 3:51 pm

Re: How to set up a static IP using Raspbian Buster

Mon Jul 15, 2019 3:35 pm

I reverted them back to the original state

epoch1970
Posts: 3572
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to set up a static IP using Raspbian Buster

Mon Jul 15, 2019 3:41 pm

Good move.
It is better to configure your router to give always the same IP address to a machine, rather than fiddling with manual IP config.
See the configuration pages of the DHCP server in your router.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

sandy1
Posts: 4
Joined: Sat Jul 13, 2019 3:51 pm

Re: How to set up a static IP using Raspbian Buster

Mon Jul 15, 2019 3:42 pm

Have solved the problem. I made the correct edits to /etc/dhcpcd.conf, but then added this line to /etc/network/interfaces:

Code: Select all

interface eth0 manual
A quick reboot and the problem was fixed.

epoch1970
Posts: 3572
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: How to set up a static IP using Raspbian Buster

Mon Jul 15, 2019 3:58 pm

sandy1 wrote:
Mon Jul 15, 2019 3:42 pm
Have solved the problem. I made the correct edits to /etc/dhcpcd.conf, but then added this line to /etc/network/interfaces:

Code: Select all

interface eth0 manual
A quick reboot and the problem was fixed.
Editing /etc/network/interfaces is not needed nor expected in the general case (as here) in Raspbian. It's been link that for a few releases.
Glad it works for you, though.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
peterscargill
Posts: 14
Joined: Fri Apr 17, 2015 10:40 pm
Location: Northumberland
Contact: Website

Re: How to set up a static IP using Raspbian Buster

Sat Aug 10, 2019 11:16 am

Tried that interfaces trick, didnt work. Still no ip address on ETH0. With earlier Buster no problem, fully up to date yesterday, now Pi4 static addressing not working- fine on Pi3, just P4. I've been doing apt-get upgrade regularly but yesterday for the first time did apt-get didt-upgrade then apt-get dist-upgrade - Pi3 and Pi3B2 fine, everything works, but Pi4 will not form static IP address using dhcpcd.conf even with that interfaces mod. If I put the previous SD in P4, all is fine. If I put the new SD in a Pi3 all is fine
Regards

Peter Scargill (tech.scargill.net)

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

Re: How to set up a static IP using Raspbian Buster

Sat Aug 10, 2019 11:36 am

My pi4 running buster lite is fully up to date as of yesterday and static IP set in dhcpcd.conf still works just fine without the need for any additional lines in interfaces files.

So is your static IP outside of the address range that your router DHCP can address ?

may be post the contents of your dhcpcd.conf file.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

Return to “Networking and servers”