Aguscao
Posts: 19
Joined: Fri May 07, 2021 9:18 am

How to set Private Static IP for my Raspberry Pi

Wed May 12, 2021 3:23 pm

Hello,
How to set private static ip for my Raspberry Pi?

I have tried this:
# Example static IP configuration:
interface eth0
static ip_address=192.168.1.104/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 fd51:42f8:caae:d92e::1

# 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.104/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

It's not working. I always get dynamic IP from my DHCP which always change.

Please guide me. I am new to Raspberry Pi. Thank you.

drgeoff
Posts: 11936
Joined: Wed Jan 25, 2012 6:39 pm

Re: How to set Private Static IP for my Raspberry Pi

Wed May 12, 2021 4:16 pm

Assuming you are using RPI OS. https://www.raspberrypi.org/documentati ... /README.md

1. Delete those two "fallback" sections.

2. Did you make any changes to the interfaces file? (Hint: You should not have.)
Quis custodiet ipsos custodes?

Aguscao
Posts: 19
Joined: Fri May 07, 2021 9:18 am

Re: How to set Private Static IP for my Raspberry Pi

Thu May 13, 2021 7:38 pm

drgeoff wrote:
Wed May 12, 2021 4:16 pm
Assuming you are using RPI OS. https://www.raspberrypi.org/documentati ... /README.md

1. Delete those two "fallback" sections.

2. Did you make any changes to the interfaces file? (Hint: You should not have.)
I have tried it and it is still not working. It still has new private static IP every time I boot it.
No, I did not make any changes to the interface file. In fact, I don't know which file is the interface file.

buchalvi
Posts: 28
Joined: Thu Mar 04, 2021 12:24 pm

Re: How to set Private Static IP for my Raspberry Pi

Thu May 13, 2021 8:24 pm

Presumably, you made changes in

Code: Select all

/etc/dhcpcd.conf
? If so, could you share the output of

Code: Select all

systemctl status dhcpcd.service
?
\/
Want to Transform an RPi board into a secure router?

Want to try an alternative OS to OpenWrt?

Try
https://www.github.com/mahsank/pi-router
\/

Aguscao
Posts: 19
Joined: Fri May 07, 2021 9:18 am

Re: How to set Private Static IP for my Raspberry Pi

Fri May 14, 2021 3:05 am

buchalvi wrote:
Thu May 13, 2021 8:24 pm
Presumably, you made changes in /etc/dhcpcd.conf? If so, could you share the output of systemctl status dhcpcd.service?
Yes, I did change /etc/dhcpcd.conf.

Here is the content of my /etc/dhcpcd.conf:

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

# Example static IP configuration:
interface eth0
static ip_address=192.168.1.104/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 fd51:42f8:caae:d92e::1

# 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.104/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
Here is the output of systemctl status dhcpcd.service:

Code: Select all

pi@raspberrypi:~ $ systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-05-14 09:27:56 WIB; 9min ago
  Process: 269 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b (code=exited, status=0/SUCCESS)
 Main PID: 291 (dhcpcd)
    Tasks: 2 (limit: 877)
   CGroup: /system.slice/dhcpcd.service
           ├─291 /sbin/dhcpcd -q -b
           └─413 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -Dnl80211,we

May 14 09:28:14 raspberrypi dhcpcd[291]: wlan0: connected to Access Point `AgusAndromaxM6'
May 14 09:28:14 raspberrypi dhcpcd[291]: wlan0: IAID ef:60:3e:fa
May 14 09:28:14 raspberrypi dhcpcd[291]: wlan0: adding address fe80::a4e4:7a76:ec1c:d728
May 14 09:28:14 raspberrypi dhcpcd[291]: wlan0: soliciting an IPv6 router
May 14 09:28:15 raspberrypi dhcpcd[291]: wlan0: rebinding lease of 192.168.1.110
May 14 09:28:19 raspberrypi dhcpcd[291]: wlan0: probing address 192.168.1.110/24
May 14 09:28:23 raspberrypi dhcpcd[291]: wlan0: leased 192.168.1.110 for 86400 seconds
May 14 09:28:23 raspberrypi dhcpcd[291]: wlan0: adding route to 192.168.1.0/24
May 14 09:28:23 raspberrypi dhcpcd[291]: wlan0: adding default route via 192.168.1.1
May 14 09:28:28 raspberrypi dhcpcd[291]: wlan0: no IPv6 Routers available
lines 1-20/20 (END)
As you can see, the /etc/dhcpcd.conf is not working. I get different ip every time I boot my Raspberry Pi. Please advice me on this matter. Thank you.

bls
Posts: 1465
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: How to set Private Static IP for my Raspberry Pi

Fri May 14, 2021 3:23 am

Aguscao wrote:
Fri May 14, 2021 3:05 am
buchalvi wrote:
Thu May 13, 2021 8:24 pm
Presumably, you made changes in /etc/dhcpcd.conf? If so, could you share the output of systemctl status dhcpcd.service?
Yes, I did change /etc/dhcpcd.conf.

Here is the content of my /etc/dhcpcd.conf:

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

# Example static IP configuration:
interface eth0
static ip_address=192.168.1.104/24
static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8 fd51:42f8:caae:d92e::1

# 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.104/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
Here is the output of systemctl status dhcpcd.service:

Code: Select all

pi@raspberrypi:~ $ systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-05-14 09:27:56 WIB; 9min ago
  Process: 269 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b (code=exited, status=0/SUCCESS)
 Main PID: 291 (dhcpcd)
    Tasks: 2 (limit: 877)
   CGroup: /system.slice/dhcpcd.service
           ├─291 /sbin/dhcpcd -q -b
           └─413 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -Dnl80211,we

May 14 09:28:14 raspberrypi dhcpcd[291]: wlan0: connected to Access Point `AgusAndromaxM6'
May 14 09:28:14 raspberrypi dhcpcd[291]: wlan0: IAID ef:60:3e:fa
May 14 09:28:14 raspberrypi dhcpcd[291]: wlan0: adding address fe80::a4e4:7a76:ec1c:d728
May 14 09:28:14 raspberrypi dhcpcd[291]: wlan0: soliciting an IPv6 router
May 14 09:28:15 raspberrypi dhcpcd[291]: wlan0: rebinding lease of 192.168.1.110
May 14 09:28:19 raspberrypi dhcpcd[291]: wlan0: probing address 192.168.1.110/24
May 14 09:28:23 raspberrypi dhcpcd[291]: wlan0: leased 192.168.1.110 for 86400 seconds
May 14 09:28:23 raspberrypi dhcpcd[291]: wlan0: adding route to 192.168.1.0/24
May 14 09:28:23 raspberrypi dhcpcd[291]: wlan0: adding default route via 192.168.1.1
May 14 09:28:28 raspberrypi dhcpcd[291]: wlan0: no IPv6 Routers available
lines 1-20/20 (END)
As you can see, the /etc/dhcpcd.conf is not working. I get different ip every time I boot my Raspberry Pi. Please advice me on this matter. Thank you.
If you're not actually using IPV6 (and I'm guessing you're not since the "static ip6_address=fd51:42f8:caae:d92e::ff/64" is exactly what's in the default dhcpcd.conf), please do the following:
  • Comment out or delete the line: static ip6_address=fd51:42f8:caae:d92e::ff/64
  • Remove fd51:42f8:caae:d92e::1 from the "static domain_name_servers" line, which is also from the default dhcpcd.conf
  • Reboot your system
  • Post the result of the command sudo journalctl -b | grep dhcpcd in code tags for us to see
  • If you don't think the result is correct, please explain why it's not
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Aguscao
Posts: 19
Joined: Fri May 07, 2021 9:18 am

Re: How to set Private Static IP for my Raspberry Pi

Fri May 14, 2021 4:09 am

bls wrote:
Fri May 14, 2021 3:23 am
If you're not actually using IPV6 (and I'm guessing you're not since the "static ip6_address=fd51:42f8:caae:d92e::ff/64" is exactly what's in the default dhcpcd.conf), please do the following:
  • Comment out or delete the line: static ip6_address=fd51:42f8:caae:d92e::ff/64
  • Remove fd51:42f8:caae:d92e::1 from the "static domain_name_servers" line, which is also from the default dhcpcd.conf
  • Reboot your system
  • Post the result of the command sudo journalctl -b | grep dhcpcd in code tags for us to see
  • If you don't think the result is correct, please explain why it's not
I don't think it is working either, because now the IP has changed to 192.168.1.111 instead of 192.168.1.104 as configured. I don't really know why it's not working.

Here is the result of sudo journalctl -b | grep dhcpcd:

Code: Select all

pi@raspberrypi:~ $ sudo journalctl -b | grep dhcpcd
May 14 10:48:00 raspberrypi systemd[1]: Starting dhcpcd on all interfaces...
May 14 10:48:01 raspberrypi dhcpcd[280]: dev: loaded udev
May 14 10:48:02 raspberrypi dhcpcd[280]: forked to background, child pid 309
May 14 10:48:03 raspberrypi systemd[1]: Started dhcpcd on all interfaces.
May 14 10:48:03 raspberrypi dhcpcd[309]: eth0: waiting for carrier
May 14 10:48:11 raspberrypi dhcpcd-run-hooks[396]: wlan0: starting wpa_supplicant
May 14 10:48:16 raspberrypi dhcpcd[309]: wlan0: connected to Access Point `'
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: waiting for carrier
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: carrier acquired
May 14 10:48:17 raspberrypi dhcpcd[309]: DUID 00:01:00:01:27:d4:25:bc:00:13:ef:60:3e:fa
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: IAID ef:60:3e:fa
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: adding address fe80::2c6b:3d45:e80d:57
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: carrier lost
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: deleting address fe80::2c6b:3d45:e80d:57
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: carrier acquired
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: connected to Access Point `AgusAndromaxM6'
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: IAID ef:60:3e:fa
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: adding address fe80::a4e4:7a76:ec1c:d728
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: rebinding lease of 192.168.1.110
May 14 10:48:20 raspberrypi dhcpcd[309]: wlan0: soliciting an IPv6 router
May 14 10:48:24 raspberrypi dhcpcd[309]: wlan0: probing for an IPv4LL address
May 14 10:48:24 raspberrypi dhcpcd[309]: wlan0: DHCP lease expired
May 14 10:48:25 raspberrypi dhcpcd[309]: wlan0: soliciting a DHCP lease
May 14 10:48:25 raspberrypi dhcpcd[309]: wlan0: offered 192.168.1.110 from 192.168.1.1
May 14 10:48:25 raspberrypi dhcpcd[309]: wlan0: NAK: from 192.168.1.1
May 14 10:48:25 raspberrypi dhcpcd[309]: wlan0: soliciting a DHCP lease
May 14 10:48:26 raspberrypi dhcpcd[309]: wlan0: offered 192.168.1.111 from 192.168.1.1
May 14 10:48:26 raspberrypi dhcpcd[309]: wlan0: probing address 192.168.1.111/24
May 14 10:48:29 raspberrypi dhcpcd[309]: wlan0: using IPv4LL address 169.254.92.8
May 14 10:48:29 raspberrypi dhcpcd[309]: wlan0: adding route to 169.254.0.0/16
May 14 10:48:29 raspberrypi dhcpcd[309]: wlan0: adding default route
May 14 10:48:32 raspberrypi dhcpcd[309]: wlan0: leased 192.168.1.111 for 86400 seconds
May 14 10:48:32 raspberrypi dhcpcd[309]: wlan0: adding route to 192.168.1.0/24
May 14 10:48:32 raspberrypi dhcpcd[309]: wlan0: changing default route via 192.168.1.1
May 14 10:48:34 raspberrypi dhcpcd[309]: wlan0: deleting route to 169.254.0.0/16
May 14 10:48:34 raspberrypi dhcpcd[309]: wlan0: no IPv6 Routers available
May 14 10:48:34 raspberrypi dhcpcd[309]: wlan0: pid 309 deleted default route via 192.168.1.1
and this is my /etc/dhcpcd.conf now:

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

# Example static IP configuration:
interface eth0
static ip_address=192.168.1.104/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
#static domain_name_servers=192.168.1.1 8.8.8.8 fd51:42f8:caae:d92e::1
static domain_name_servers=192.168.1.1 8.8.8.8

# 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.104/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
And in case you need to see, here is my config.txt:

Code: Select all

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d
max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
hdmi_drive=1

dtoverlay=ads7846,penirq=22

My wi-fi only has 3 connections: my laptop (IP 192.168.1.102), my cellphone (IP 192.168.1.101), and m Raspberry Pi (currently IP 192.168.1.111).

Did I do anything wrong? Do you need to see some other configurations?

bls
Posts: 1465
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: How to set Private Static IP for my Raspberry Pi

Fri May 14, 2021 5:05 am

Aguscao wrote:
Fri May 14, 2021 4:09 am

I don't think it is working either, because now the IP has changed to 192.168.1.111 instead of 192.168.1.104 as configured. I don't really know why it's not working.

Here is the result of sudo journalctl -b | grep dhcpcd:

Code: Select all

pi@raspberrypi:~ $ sudo journalctl -b | grep dhcpcd
May 14 10:48:00 raspberrypi systemd[1]: Starting dhcpcd on all interfaces...
May 14 10:48:01 raspberrypi dhcpcd[280]: dev: loaded udev
May 14 10:48:02 raspberrypi dhcpcd[280]: forked to background, child pid 309
May 14 10:48:03 raspberrypi systemd[1]: Started dhcpcd on all interfaces.
May 14 10:48:03 raspberrypi dhcpcd[309]: eth0: waiting for carrier
May 14 10:48:11 raspberrypi dhcpcd-run-hooks[396]: wlan0: starting wpa_supplicant
May 14 10:48:16 raspberrypi dhcpcd[309]: wlan0: connected to Access Point `'
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: waiting for carrier
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: carrier acquired
May 14 10:48:17 raspberrypi dhcpcd[309]: DUID 00:01:00:01:27:d4:25:bc:00:13:ef:60:3e:fa
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: IAID ef:60:3e:fa
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: adding address fe80::2c6b:3d45:e80d:57
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: carrier lost
May 14 10:48:17 raspberrypi dhcpcd[309]: wlan0: deleting address fe80::2c6b:3d45:e80d:57
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: carrier acquired
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: connected to Access Point `AgusAndromaxM6'
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: IAID ef:60:3e:fa
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: adding address fe80::a4e4:7a76:ec1c:d728
May 14 10:48:19 raspberrypi dhcpcd[309]: wlan0: rebinding lease of 192.168.1.110
May 14 10:48:20 raspberrypi dhcpcd[309]: wlan0: soliciting an IPv6 router
May 14 10:48:24 raspberrypi dhcpcd[309]: wlan0: probing for an IPv4LL address
May 14 10:48:24 raspberrypi dhcpcd[309]: wlan0: DHCP lease expired
May 14 10:48:25 raspberrypi dhcpcd[309]: wlan0: soliciting a DHCP lease
May 14 10:48:25 raspberrypi dhcpcd[309]: wlan0: offered 192.168.1.110 from 192.168.1.1
May 14 10:48:25 raspberrypi dhcpcd[309]: wlan0: NAK: from 192.168.1.1
May 14 10:48:25 raspberrypi dhcpcd[309]: wlan0: soliciting a DHCP lease
May 14 10:48:26 raspberrypi dhcpcd[309]: wlan0: offered 192.168.1.111 from 192.168.1.1
May 14 10:48:26 raspberrypi dhcpcd[309]: wlan0: probing address 192.168.1.111/24
May 14 10:48:29 raspberrypi dhcpcd[309]: wlan0: using IPv4LL address 169.254.92.8
May 14 10:48:29 raspberrypi dhcpcd[309]: wlan0: adding route to 169.254.0.0/16
May 14 10:48:29 raspberrypi dhcpcd[309]: wlan0: adding default route
May 14 10:48:32 raspberrypi dhcpcd[309]: wlan0: leased 192.168.1.111 for 86400 seconds
May 14 10:48:32 raspberrypi dhcpcd[309]: wlan0: adding route to 192.168.1.0/24
May 14 10:48:32 raspberrypi dhcpcd[309]: wlan0: changing default route via 192.168.1.1
May 14 10:48:34 raspberrypi dhcpcd[309]: wlan0: deleting route to 169.254.0.0/16
May 14 10:48:34 raspberrypi dhcpcd[309]: wlan0: no IPv6 Routers available
May 14 10:48:34 raspberrypi dhcpcd[309]: wlan0: pid 309 deleted default route via 192.168.1.1
and this is my /etc/dhcpcd.conf now:

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

# Example static IP configuration:
interface eth0
static ip_address=192.168.1.104/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
static routers=192.168.1.1
#static domain_name_servers=192.168.1.1 8.8.8.8 fd51:42f8:caae:d92e::1
static domain_name_servers=192.168.1.1 8.8.8.8

# 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.104/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
And in case you need to see, here is my config.txt:

Code: Select all

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable infrared communication.
#dtoverlay=gpio-ir,gpio_pin=17
#dtoverlay=gpio-ir-tx,gpio_pin=18

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835)
dtparam=audio=on

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

[all]
#dtoverlay=vc4-fkms-v3d
max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 800 480 60 6 0 0 0
hdmi_drive=1

dtoverlay=ads7846,penirq=22

My wi-fi only has 3 connections: my laptop (IP 192.168.1.102), my cellphone (IP 192.168.1.101), and m Raspberry Pi (currently IP 192.168.1.111).

Did I do anything wrong? Do you need to see some other configurations?
Sorry, I'm confused. Which device is having the problem? eth0 or wlan0? You have configured a static address for eth0 in your dhcpcd.conf, and there's no configuration for wlan0 there, but it looks like eth0 isn't connected to anything (eth0: waiting for carrier).

Please clarify which device you think is a problem. If it's the wireless, then change all the eth0 settings in your dhcpcd.conf to wlan0, try it again, and report the full results here.

If it's eth0 that you want to configure, then you're going to need to connect it, get a working ethernet cable, or otherwise correct the problem that results in the Pi not detecting carrier.
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Aguscao
Posts: 19
Joined: Fri May 07, 2021 9:18 am

Re: How to set Private Static IP for my Raspberry Pi

Fri May 14, 2021 6:32 am

bls wrote:
Fri May 14, 2021 5:05 am
Sorry, I'm confused. Which device is having the problem? eth0 or wlan0? You have configured a static address for eth0 in your dhcpcd.conf, and there's no configuration for wlan0 there, but it looks like eth0 isn't connected to anything (eth0: waiting for carrier).

Please clarify which device you think is a problem. If it's the wireless, then change all the eth0 settings in your dhcpcd.conf to wlan0, try it again, and report the full results here.

If it's eth0 that you want to configure, then you're going to need to connect it, get a working ethernet cable, or otherwise correct the problem that results in the Pi not detecting carrier.
OK, now it is running. Thanks.
Now I get it. Eth0 is for connections with ethernet cable and wlan0 is for connections with wireless lan.
I didn't know this before. Now I understand.

Thank you all for helping me. I wouldn't know this if I didn't ask for help. Once again thank you.
I still have many questions regarding Raspberry Pi, but they are for another time. Thanks.

bls
Posts: 1465
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: How to set Private Static IP for my Raspberry Pi

Fri May 14, 2021 1:20 pm

Aguscao wrote:
Fri May 14, 2021 6:32 am
bls wrote:
Fri May 14, 2021 5:05 am
Sorry, I'm confused. Which device is having the problem? eth0 or wlan0? You have configured a static address for eth0 in your dhcpcd.conf, and there's no configuration for wlan0 there, but it looks like eth0 isn't connected to anything (eth0: waiting for carrier).

Please clarify which device you think is a problem. If it's the wireless, then change all the eth0 settings in your dhcpcd.conf to wlan0, try it again, and report the full results here.

If it's eth0 that you want to configure, then you're going to need to connect it, get a working ethernet cable, or otherwise correct the problem that results in the Pi not detecting carrier.
OK, now it is running. Thanks.
Now I get it. Eth0 is for connections with ethernet cable and wlan0 is for connections with wireless lan.
I didn't know this before. Now I understand.

Thank you all for helping me. I wouldn't know this if I didn't ask for help. Once again thank you.
I still have many questions regarding Raspberry Pi, but they are for another time. Thanks.
Glad you got it working. As you've discovered, naming is VERY important! Good luck on your Linux journey.
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Return to “Networking and servers”