DHCP to Static

Got my Pi’s running fairly sweet but want to make a iP change to make things a bit nicer on my LAN. Currently on DHCP and want to set a Static iP instead. I tried this once before and my feeds just stopped working. Can somebody point me at the best method to reconfigure without screwing things up.

Which image, piaware or Raspbian?

PRETTY_NAME=“Raspbian GNU/Linux 10 (buster)”

Which dhcp client?

pgrep dhcpcd
pgrep dhclient

pgrep dhcpcd = 535
pgrep dhclient = Nothing returned

dhcpcd - ArchWiki

You can check the current settings:
ip a

Just post what you would add to dhcpcd.conf so you don’t shut yourself out.

Sorry mate. You lost me there. I know what the config is. Just need to know what the best method is to change to static

You use dhcpd to configure the static ip.
Easiest.

As far as I know dhcpd.conf is for when the pi is the server and you might change that to set the parameters for the clients on the network. My dhcp server is my router. Sorry but im just making sure im understanding correctly

No you don’t understand.

dhcpcd is the dhcp client.
But it can easily set a static ip if you configure it for it.

Show current IP:

ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
link/ether dc:a6:32:1c:e3:ef brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether dc:a7:16:1a:e4:c1 brd ff:ff:ff:ff:ff:ff
inet 169.0.1.169/24 brd 169.0.1.250 scope global dynamic noprefixroute wlan0
valid_lft 828277sec preferred_lft 720277sec
inet6 fe80::d68:8ca:9066:6f03/64 scope link
valid_lft forever preferred_lft forever

So you add this do /etc/dhcpcd.conf

interface wlan0
static ip_address=169.0.1.222/24
static routers=169.0.1.1
static domain_name_servers=8.8.4.4 8.8.8.8

The router IP you need to adjust if it’s something different.
route -n should tell you the router IP.

After changing dhcpcd.conf you just:

sudo systemctl restart dhcpcd

Sorry for the delay. Had to go to sons school assembly.

All the above worked a treat and the address changed without impact to my feed. Thankyou

I have tried the same a few times on Stretch but that isnt working,

Solved it. Looked into my router to find that it was set to provide a static iP. Regardless what I did to the pi it was going to get the same address.

@wiedehopf Many thanks for you time. Appreciated

I never assign static IPs in devices because to change IPs one must touch those devices. Instead I make reservations (by mac address) for IP addresses in a router or other DHCP server. Then IP address maintenance for an entire network can be accomplished at a single point - the DHCP server. Another advantage of this method is if a device is moved to another network such as when traveling it will work without configuration changes.

5 Likes