一个子问题:为什么我的客户端请求特定的 IP 地址而不dhclient
运行?
我有两个接入点。一种提供两个 SSID,另一种仅提供一个 SSID。当我连接到双 SSID AP 时,我会分配两个 IP 地址。当我连接到另一个接入点时,我仅获得一个 IP 地址。如果我随后切换回来,我又会获得两个 IP 地址。为什么会发生这种情况? (请注意,我在网上找到的所有讨论都是为了获取两个 IP 地址,而不是关于不需要的地址
我已连接到 Raspberry Pi。我正在通过 NFS 运行多个 Pi,其中包含列入黑名单的板载 Broadcomm Wifi 和 USB Realtek WiFi 适配器(对我来说方便的测试设置)。我已经关闭了除一个 Pi 之外的所有 Pi,但是我已经重新启动了正在运行的 Pi 几次,结果相同。我还重新启动了 AP。
背景信息
我正在使用的关联命令是
nmcli device wifi connect abcdefg ifname wlan0 password hijklmnop
这是关联后的配置(通过在关联过程中多次运行命令观察到,dynamic
地址是在地址之前不久分配的)。secondary
forever
pi@rpinode:~ $ ip a
...
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether bc:ec:23:c3:1d:0b brd ff:ff:ff:ff:ff:ff
inet 10.61.1.90/16 brd 10.61.255.255 scope global dynamic wlan0
valid_lft 43038sec preferred_lft 43038sec
inet 10.61.1.84/16 brd 10.61.255.255 scope global secondary wlan0
valid_lft forever preferred_lft forever
请注意,ifconfig
仅显示dynamic
地址(也许并不奇怪 - 但只是指出这不是别名)。
就在门外,Pi 正在请求一个特定的地址,尽管/etc/dhcp/dhclient.conf
似乎并没有请求这样的事情。以下是该文件中的非注释行:
# /etc/dhcp/dhclient.conf
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
dhcp6.name-servers, dhcp6.domain-search,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
这是 dhcpdump 输出,您将看到 Pi 在连接到同一 IP 上的其他 SSID 时请求其收到的 IP 辅助 IP 地址。请注意,我在运行上述nmcli
命令之前启动了此命令。
pi@rpinode:~ $ sudo dhcpdump -i wlan0
TIME: 2019-05-07 14:17:03.276
IP: 0.0.0.0 (bc:ec:23:c3:1d:b) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
OP: 1 (BOOTPREQUEST)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 431be597
SECS: 0
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 3 (DHCPREQUEST)
OPTION: 61 ( 7) Client-identifier 01:bc:ec:23:c3:1d:0b
OPTION: 50 ( 4) Request IP address 192.168.1.144
OPTION: 57 ( 2) Maximum DHCP message size 1500
OPTION: 60 ( 44) Vendor class identifier dhcpcd-6.7.1:Linux-4.9.35-v7+:armv7l:BCM2835
OPTION: 12 ( 7) Host name rpinode
OPTION: 145 ( 1) ??? 01 .
OPTION: 55 ( 14) Parameter Request List 1 (Subnet mask)
121 (Classless Static Route)
33 (Static route)
3 (Routers)
6 (DNS server)
12 (Host name)
15 (Domainname)
28 (Broadcast address)
42 (NTP servers)
51 (IP address leasetime)
54 (Server identifier)
58 (T1)
59 (T2)
119 (Domain Search)
---------------------------------------------------------------------------
TIME: 2019-05-07 14:17:03.278
IP: 10.61.0.1 (xx:xx:xx:xx:xx:xx) > 255.255.255.255 (bc:ec:23:c3:1d:b)
OP: 2 (BOOTPREPLY)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 431be597
SECS: 0
FLAGS: 7f80
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 10.61.0.1
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 6 (DHCPNAK)
OPTION: 54 ( 4) Server identifier 10.61.0.1
OPTION: 56 ( 31) Message requested address not available
---------------------------------------------------------------------------
TIME: 2019-05-07 14:17:03.606
IP: 0.0.0.0 (bc:ec:23:c3:1d:b) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
OP: 1 (BOOTPREQUEST)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 9f05d956
SECS: 1
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 1 (DHCPDISCOVER)
OPTION: 61 ( 7) Client-identifier 01:bc:ec:23:c3:1d:0b
OPTION: 80 ( 0) Naming Authority
OPTION: 116 ( 1) DHCP Autoconfiguration 01 .
OPTION: 57 ( 2) Maximum DHCP message size 1500
OPTION: 60 ( 44) Vendor class identifier dhcpcd-6.7.1:Linux-4.9.35-v7+:armv7l:BCM2835
OPTION: 12 ( 7) Host name rpinode
OPTION: 145 ( 1) ??? 01 .
OPTION: 55 ( 14) Parameter Request List 1 (Subnet mask)
121 (Classless Static Route)
33 (Static route)
3 (Routers)
6 (DNS server)
12 (Host name)
15 (Domainname)
28 (Broadcast address)
42 (NTP servers)
51 (IP address leasetime)
54 (Server identifier)
58 (T1)
59 (T2)
119 (Domain Search)
---------------------------------------------------------------------------
TIME: 2019-05-07 14:17:03.607
IP: 0.0.0.0 (bc:ec:23:c3:1d:b) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
OP: 1 (BOOTPREQUEST)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 97268832
SECS: 0
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 1 (DHCPDISCOVER)
OPTION: 12 ( 7) Host name rpinode
OPTION: 55 ( 18) Parameter Request List 1 (Subnet mask)
28 (Broadcast address)
2 (Time offset)
3 (Routers)
15 (Domainname)
6 (DNS server)
119 (Domain Search)
12 (Host name)
44 (NetBIOS name server)
47 (NetBIOS scope)
26 (Interface MTU)
121 (Classless Static Route)
42 (NTP servers)
121 (Classless Static Route)
249 (MSFT - Classless route)
33 (Static route)
252 (MSFT - WinSock Proxy Auto Detect)
42 (NTP servers)
---------------------------------------------------------------------------
TIME: 2019-05-07 14:17:04.486
IP: 10.61.0.1 (xx:xx:xx:xx:xx:xx) > 10.61.1.84 (bc:ec:23:c3:1d:b)
OP: 2 (BOOTPREPLY)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 9f05d956
SECS: 1
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 10.61.1.84
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 2 (DHCPOFFER)
OPTION: 54 ( 4) Server identifier 10.61.0.1
OPTION: 51 ( 4) IP address leasetime 43200 (12h)
OPTION: 1 ( 4) Subnet mask 255.255.0.0
OPTION: 3 ( 4) Routers 10.61.0.1
OPTION: 6 ( 4) DNS server 10.61.0.1
OPTION: 15 ( 18) Domainname myownurl.com
OPTION: 58 ( 4) T1 21600 (6h)
OPTION: 59 ( 4) T2 37800 (10h30m)
---------------------------------------------------------------------------
TIME: 2019-05-07 14:17:04.486
IP: 10.61.0.1 (xx:xx:xx:xx:xx:xx) > 10.61.1.90 (bc:ec:23:c3:1d:b)
OP: 2 (BOOTPREPLY)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 97268832
SECS: 0
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 10.61.1.90
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 2 (DHCPOFFER)
OPTION: 54 ( 4) Server identifier 10.61.0.1
OPTION: 51 ( 4) IP address leasetime 43200 (12h)
OPTION: 1 ( 4) Subnet mask 255.255.0.0
OPTION: 3 ( 4) Routers 10.61.0.1
OPTION: 15 ( 18) Domainname myownurl.com
OPTION: 6 ( 4) DNS server 10.61.0.1
---------------------------------------------------------------------------
TIME: 2019-05-07 14:17:04.487
IP: 0.0.0.0 (bc:ec:23:c3:1d:b) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
OP: 1 (BOOTPREQUEST)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 97268832
SECS: 0
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 3 (DHCPREQUEST)
OPTION: 54 ( 4) Server identifier 10.61.0.1
OPTION: 50 ( 4) Request IP address 10.61.1.90
OPTION: 12 ( 7) Host name rpinode
OPTION: 55 ( 18) Parameter Request List 1 (Subnet mask)
28 (Broadcast address)
2 (Time offset)
3 (Routers)
15 (Domainname)
6 (DNS server)
119 (Domain Search)
12 (Host name)
44 (NetBIOS name server)
47 (NetBIOS scope)
26 (Interface MTU)
121 (Classless Static Route)
42 (NTP servers)
121 (Classless Static Route)
249 (MSFT - Classless route)
33 (Static route)
252 (MSFT - WinSock Proxy Auto Detect)
42 (NTP servers)
---------------------------------------------------------------------------
TIME: 2019-05-07 14:17:04.487
IP: 0.0.0.0 (bc:ec:23:c3:1d:b) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
OP: 1 (BOOTPREQUEST)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 9f05d956
SECS: 2
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 3 (DHCPREQUEST)
OPTION: 61 ( 7) Client-identifier 01:bc:ec:23:c3:1d:0b
OPTION: 50 ( 4) Request IP address 10.61.1.84
OPTION: 54 ( 4) Server identifier 10.61.0.1
OPTION: 57 ( 2) Maximum DHCP message size 1500
OPTION: 60 ( 44) Vendor class identifier dhcpcd-6.7.1:Linux-4.9.35-v7+:armv7l:BCM2835
OPTION: 12 ( 7) Host name rpinode
OPTION: 145 ( 1) ??? 01 .
OPTION: 55 ( 14) Parameter Request List 1 (Subnet mask)
121 (Classless Static Route)
33 (Static route)
3 (Routers)
6 (DNS server)
12 (Host name)
15 (Domainname)
28 (Broadcast address)
42 (NTP servers)
51 (IP address leasetime)
54 (Server identifier)
58 (T1)
59 (T2)
119 (Domain Search)
---------------------------------------------------------------------------
TIME: 2019-05-07 14:17:04.488
IP: 10.61.0.1 (xx:xx:xx:xx:xx:xx) > 10.61.1.90 (bc:ec:23:c3:1d:b)
OP: 2 (BOOTPREPLY)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 97268832
SECS: 0
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 10.61.1.90
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 5 (DHCPACK)
OPTION: 54 ( 4) Server identifier 10.61.0.1
OPTION: 51 ( 4) IP address leasetime 43200 (12h)
OPTION: 1 ( 4) Subnet mask 255.255.0.0
OPTION: 3 ( 4) Routers 10.61.0.1
OPTION: 15 ( 18) Domainname myownurl.com
OPTION: 6 ( 4) DNS server 10.61.0.1
---------------------------------------------------------------------------
TIME: 2019-05-07 14:17:04.489
IP: 10.61.0.1 (xx:xx:xx:xx:xx:xx) > 10.61.1.84 (bc:ec:23:c3:1d:b)
OP: 2 (BOOTPREPLY)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 9f05d956
SECS: 2
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 10.61.1.84
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: bc:ec:23:c3:1d:0b:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 5 (DHCPACK)
OPTION: 54 ( 4) Server identifier 10.61.0.1
OPTION: 51 ( 4) IP address leasetime 43200 (12h)
OPTION: 1 ( 4) Subnet mask 255.255.0.0
OPTION: 3 ( 4) Routers 10.61.0.1
OPTION: 6 ( 4) DNS server 10.61.0.1
OPTION: 15 ( 18) Domainname myownurl.com
OPTION: 58 ( 4) T1 21600 (6h)
OPTION: 59 ( 4) T2 37800 (10h30m)
---------------------------------------------------------------------------
我从服务器获取 eth0 的 IP 地址和文件系统dnsmasq
。我认为以下内容是不正确的,但不相信它会影响我的问题。
# /etc/network/interfaces
auto lo
iface lo inet loopback
答案1
这是一个可能的答案,最终是针对我的情况的,所以可能不是“答案”。
太;博士:出现此问题的计算机是否dhcpcd5
安装了(DHCP 客户端守护程序)?如果是这样,它可能正在做自己的事情,而例如 NetworkManager 也通过 DHCP 获取 IP 地址。
我有一台 Ubuntu 20.04 机器出现此症状。在似乎很难维持与本地网络上的计算机的 SSH 连接后,人们注意到了这一点。 (相关性!=因果关系;我的设置中有很多其他不寻常的细节)
/var/log/syslog
我通过在重新启动(或者等效地,可能再次连接到网络)后查看,发现了对与dhcpcd
服务关联的第二个 IP 地址的引用。
经过检查dpkg -l | grep dhcp
并与另一台类似的计算机进行比较,我确定这台计算机已经dhcpcd5
安装了。最终/var/log/apt/history.log
表明另一位用户出于某种原因在几个月前安装了此软件。
卸载软件包 ( apt remove dhcpcd5
) 并重新启动以确保第二个 IP 地址消失。