0

One of my PC machines is conflicting with my raspberry pi because they're sharing the same local IP.

Editing the PC's static IP is not an option, lots of hard-coded things set to this IP.

I've set both the Pi's eth0 and wlan0 interfaces to static ip 192.168.1.22:

/etc/dhcp/dhclient.conf:

interface eth0
static ip_address=192.168.1.22/24
static routers=2001:520:ff02:12b::68
static domain_name_servers=2001:520:ff02:12b::68

interface wlan0 static ip_address=192.168.1.20/24 static routers=2001:520:ff02:12b::68 static domain_name_servers=2001:520:ff02:12b::68

PC uses 192.168.1.21

Pi should be using 192.168.1.22, but its wlan0 interface keeps getting set to 192.168.1.21:

default via 192.168.1.254 dev eth0 proto dhcp src **192.168.1.22** metric 100
default via 192.168.1.254 dev wlan0 proto dhcp src **192.168.1.21** metric 600

What am I doing wrong? How do I set the Pi's ethernet and wifi static IP addresses to 192.168.1.22?

EDIT: I changed the wlan0 static ip to 192.168.1.20 but it's still using 192.168.1.21...

EDIT 2: Script output:

[36m- Networking System
(B[0mNetworkManager active
networking active
[36m- IP addresses & routes
(B[0m1: 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 noprefixroute 
       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:65:3e:78 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.22/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
       valid_lft 79734sec preferred_lft 79734sec
    inet6 2001:569:5b0c:d500:3300:2bb5:7d7d:821c/64 scope global dynamic noprefixroute 
       valid_lft 14595sec preferred_lft 14295sec
    inet6 fe80::d3ac:38:75b1:c922/64 scope link noprefixroute 
       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:30:6b:2d brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.21/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0
       valid_lft 79740sec preferred_lft 79740sec
    inet6 2001:569:5b0c:d500:cb03:8354:c6bf:104b/64 scope global dynamic noprefixroute 
       valid_lft 14595sec preferred_lft 14295sec
    inet6 fe80::37b5:9170:5012:e133/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

default via 192.168.1.254 dev eth0 proto dhcp src 192.168.1.22 metric 100 default via 192.168.1.254 dev wlan0 proto dhcp src 192.168.1.21 metric 600 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.22 metric 100 192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.21 metric 600 [36m- Network Devices (B[0meth0 lo wlan0 [36m- Connected WiFi (B[0mPromotedNetwork [36m- Available WiFi connections (B[0mPromotedNetwork PromotedNetwork

1 Answers1

0

You can't assign the same address to 2 interfaces (unless you use a bridge - in which case you assign the IP to the bridge).

Setting a static IP address is a Pi disease, rarely necessary on a network with a DHCP server. If you have some reason reserve in your router.


Try running the following to find out what you actually have

#! /bin/sh
# This script prints useful diagnostics for common Pi networking systems

Function to print coloured headings

delete "tput" lines for plain output

print_head () { tput setaf 6 echo $1 tput sgr 0 }

checkactive () { if [ $(systemctl is-active $1) = 'active' ]; then echo $1 'active' fi }

print_head "- Networking System"

Check status of networking system

checkactive 'systemd-networkd' checkactive 'dhcpcd' checkactive 'NetworkManager' checkactive 'networking'

print_head "- IP addresses & routes"

Print IP addresses & routes

ip a echo ip r

print_head "- Network Devices" ls /sys/class/net # network devices

print_head "- Connected WiFi"

Get SSID of connected WiFi (WRONG if AP!)

if [ -e /sys/class/net/wlan0 ]; then if [ $(systemctl is-active 'NetworkManager') = 'active' ]; then nmcli connection show | awk '/wlan0/ {print $1}' else wpa_cli -i wlan0 status | grep -w ssid | awk -F'[=]' '{print $2}' fi fi

print_head "- Available WiFi connections" if [ -e /sys/class/net/wlan0 ]; then if [ $(systemctl is-active 'NetworkManager') = 'active' ]; then nmcli connection show | awk '/wifi/ {print $1}' else wpa_cli list_networks | awk '/any/ {print $2}' fi fi


You are using NetworkManager so anything you put in other config files is irrelevant. What you put in dhclient.conf actually looks like a dhcpcd configuration file and certainly doesn't belong there and would't set an IP address (even if it was used).

See How do I set up networking on Raspberry Pi OS - Bookworm

Milliways
  • 62,573
  • 32
  • 113
  • 225