I am struggling getting my rPi to get a fixed IP. I have this /etc/dhcpcd.conf
, but that doesn't seem to do anything:
# 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
eth0 is our internal net
interface eth0
static ip_address=192.168.250.10/24
static routers=192.168.250.1
After a reboot, this is my IP setup:
pi@raspberrypi:/etc/systemd/network$ ip a l
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: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:ff:b7:e5 brd ff:ff:ff:ff:ff:ff
inet 169.254.25.116/16 brd 169.254.255.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:feff:b7e5/64 scope link
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:aa:e2:b0 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.233/22 brd 192.168.3.255 scope global dynamic noprefixroute wlan0
valid_lft 690622sec preferred_lft 604222sec
inet6 fe80::ba27:ebff:feaa:e2b0/64 scope link
valid_lft forever preferred_lft forever
Then, when looking for more info on this, I see that "under systemd, the network may be configured" using /etc/systemd/network
instead. But, when I read those lines correctly, it want an en*
interface, but I have an eth0
. Also, what does "may be configured" mean? Either it does it, or it doesn't, right?
Update when I manually set the interface with
pi@raspberrypi:~$ sudo ifconfig eth0 192.168.250.10
pi@raspberrypi:~$ sudo route add -net 192.168.250.0/24 eth0
I have the setup I want (except for some stray route to 169.254.0.0).
So, how can I configure my network interfaces (from the command line) on Debian 11 running on a Raspberry Pi 3 model B?
en*
vs.eth*
(oreth0
), these are just different labels an ethernet interface can end up with, you should use what is appropriate (ie.,eth0
). WRT systemd and Debian, though, beware that RpiOS differs from Debian in that by default it uses dhcpcd, and not systemd's own facilites. WRT "your internal network", to make sure: The other end of the cable is plugged into a DHCP router, right? If not you should explain what it is. – goldilocks Nov 29 '22 at 14:29request
notstatic
, see https://raspberrypi.stackexchange.com/questions/37920/how-do-i-set-up-networking-wifi-static-ip-address-on-raspbian-raspberry-pi-os (if you find a solution there, please leave a comment so this can be closed as a duplicate). – goldilocks Nov 29 '22 at 14:29