我有一台带 USB WiFi 适配器的 raspberry pi 1。wlan0 接口有 2 个 IP 地址,但我不知道为什么:
pi@smart-meter:~ $ 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
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether b8:27:eb:0e:68:e2 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 24:05:0f:b1:50:75 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.155/24 brd 192.168.2.255 scope global dynamic noprefixroute wlan0
valid_lft 86212sec preferred_lft 75412sec
inet 192.168.2.158/24 brd 192.168.2.255 scope global secondary dynamic wlan0
valid_lft 86214sec preferred_lft 86214sec
我怎样才能告诉 Raspbian 只使用一个地址?
pi@smart-meter:~ $ cat /var/lib/dhcp/dhclient.wlan0.leases
default-duid "\000\001\000\001)\226\277\334\300%\351\030\373I";
lease {
interface "wlan0";
fixed-address 192.168.2.158;
option subnet-mask 255.255.255.0;
option routers 192.168.2.1;
option dhcp-lease-time 86400;
option dhcp-message-type 5;
option domain-name-servers 192.168.2.250;
option dhcp-server-identifier 192.168.2.1;
option dhcp-renewal-time 43200;
option ntp-servers 192.168.2.1;
option broadcast-address 192.168.2.255;
option dhcp-rebinding-time 75600;
option domain-name "fritz.box";
renew 3 2022/05/11 14:08:00;
rebind 3 2022/05/11 14:08:00;
expire 3 2022/05/11 14:08:00;
}
lease {
interface "wlan0";
fixed-address 192.168.2.158;
option subnet-mask 255.255.255.0;
option routers 192.168.2.1;
option dhcp-lease-time 86400;
option dhcp-message-type 5;
option domain-name-servers 192.168.2.250;
option dhcp-server-identifier 192.168.2.1;
option dhcp-renewal-time 43200;
option ntp-servers 192.168.2.1;
option broadcast-address 192.168.2.255;
option dhcp-rebinding-time 75600;
option domain-name "fritz.box";
renew 3 2022/05/11 23:36:13;
rebind 4 2022/05/12 11:09:17;
expire 4 2022/05/12 14:09:17;
}
在 dhcpcd.conf 中我没有任何改变。/etc/network/interfaces
:
pi@smart-meter:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
#source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "xxxx"
wpa-psk xxxx
编辑:
Starting Nmap 7.60 ( https://nmap.org ) at 2022-05-11 20:04 CEST
Pre-scan script results:
| broadcast-dhcp-discover:
| Response 1 of 1:
| IP Offered: 192.168.2.105
| DHCP Message Type: DHCPOFFER
| Server Identifier: 192.168.2.1
| IP Address Lease Time: 1d00h00m00s
| Renewal Time Value: 12h00m00s
| Rebinding Time Value: 21h00m00s
| Subnet Mask: 255.255.255.0
| Router: 192.168.2.1
| Domain Name Server: 192.168.2.250
| Domain Name: fritz.box
| Broadcast Address: 192.168.2.255
|_ NTP Servers: 192.168.2.1
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 1.41 seconds