![NetworkManager 使用 dhclient 为 wlan intf 保留和设置 IP](https://linux22.com/image/219411/NetworkManager%20%E4%BD%BF%E7%94%A8%20dhclient%20%E4%B8%BA%20wlan%20intf%20%E4%BF%9D%E7%95%99%E5%92%8C%E8%AE%BE%E7%BD%AE%20IP.png)
我想为wlan0
我的客户端接口保留并分配一个预定义的 IP 地址。
我已经设定:
# cat /etc/NetworkManager/conf.d/dhcp-client.conf
:
[main]
dhcp=dhclient
# cat /etc/dhcp/dhclient.conf
:
# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
# man page for more information about the syntax of this file
# and a more comprehensive list of the parameters understood by
# dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
# not leave anything out (like the domain name, for example), then
# few changes must be made to this file, if any.
#
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, dhcp6.fqdn, dhcp6.sntp-servers,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
#send dhcp-client-identifier 192.168.0.108;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/sbin/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;
#alias {
# interface "eth0";
# fixed-address 192.5.5.213;
# option subnet-mask 255.255.255.255;
#}
#lease {
# interface "wlan0";
# fixed-address 192.168.0.108;
# medium "link0 link1";
# option host-name "banan.dev";
# option subnet-mask 255.255.255.0;
# option broadcast-address 192.33.137.255;
# option routers 192.168.0.1;
# option domain-name-servers 127.0.0.1;
# renew 2 2000/1/12 00:00:01;
# rebind 2 2000/1/12 00:00:01;
# expire 2 2000/1/12 00:00:01;
#}
host bananapim2zero {
hardware ethernet ac:6a:a3:27:8a:e1;
fixed-address 192.168.0.108;
}
# systemctl status NetworkManager.service
NetworkManager.service - Network Manager
Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-04-19 20:45:08 CEST; 6min ago
Docs: man:NetworkManager(8)
Main PID: 1103 (NetworkManager)
Tasks: 7 (limit: 888)
Memory: 11.5M
CPU: 1.274s
CGroup: /system.slice/NetworkManager.service
├─1103 /usr/sbin/NetworkManager --no-daemon
└─1303 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /run/NetworkManager/dhclient-wlan0.pid -lf /var/lib/NetworkManager/dhclient-56269e02-ee63-423f-bc6c-97067633aa9a-wlan0.lease -cf /var/lib/NetworkManager/dhclient-wlan0.conf wlan0
Apr 19 20:45:17 bananapim2zero NetworkManager[1103]: <info> [1681929917.5831] policy: set 'jebnato' (wlan0) as default for IPv4 routing and DNS
Apr 19 20:45:18 bananapim2zero NetworkManager[1103]: <info> [1681929918.2894] device (wlan0): Activation: successful, device activated.
Apr 19 20:45:18 bananapim2zero NetworkManager[1103]: <info> [1681929918.2982] manager: NetworkManager state is now CONNECTED_GLOBAL
Apr 19 20:45:18 bananapim2zero NetworkManager[1103]: <info> [1681929918.3126] manager: startup complete
Apr 19 20:45:18 bananapim2zero NetworkManager[1103]: <info> [1681929918.3193] device (wlan0): ipv6: duplicate address check failed for the fe80::1ea1:1ea:1b97:6dbd/64 lft forever pref forever lifetime 11-0[4294967295,4294967295] dev 2 flags permanent,noprefixroute,tentative,0x8 s>
Apr 19 20:45:18 bananapim2zero NetworkManager[1103]: <info> [1681929918.3196] device (wlan0): ipv6: duplicate address check failed for the fe80::f49e:9be3:cea2:c5c4/64 lft forever pref forever lifetime 11-0[4294967295,4294967295] dev 2 flags permanent,noprefixroute,tentative,0x8 >
Apr 19 20:45:18 bananapim2zero NetworkManager[1103]: <info> [1681929918.6471] device (wlan0): ipv6: duplicate address check failed for the fe80::1ea1:1ea:1b97:6dbd/64 lft forever pref forever lifetime 11-0[4294967295,4294967295] dev 2 flags permanent,noprefixroute,tentative,0x8 s>
Apr 19 20:45:19 bananapim2zero NetworkManager[1103]: <info> [1681929919.0517] device (wlan0): ipv6: duplicate address check failed for the fe80::f49e:9be3:cea2:c5c4/64 lft forever pref forever lifetime 12-0[4294967295,4294967295] dev 2 flags permanent,noprefixroute,tentative,0x8 >
Apr 19 20:45:19 bananapim2zero NetworkManager[1103]: <info> [1681929919.2169] device (wlan0): ipv6: duplicate address check failed for the fe80::2b24:4b8f:cfa4:39fe/64 lft forever pref forever lifetime 12-0[4294967295,4294967295] dev 2 flags permanent,noprefixroute,tentative,0x8 >
Apr 19 20:45:19 bananapim2zero NetworkManager[1103]: <warn> [1681929919.2172] device (wlan0): linklocal6: failed to generate an address: Too many DAD collisions
/var/lib/NetworkManager/dhclient-wlan0.conf
:
# Created by NetworkManager
# Merged from /etc/dhcp/dhclient.conf
# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
# man page for more information about the syntax of this file
# and a more comprehensive list of the parameters understood by
# dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
# not leave anything out (like the domain name, for example), then
# few changes must be made to this file, if any.
#
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
#send dhcp-client-identifier 192.168.0.108;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/sbin/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;
#alias {
# interface "eth0";
# fixed-address 192.5.5.213;
# option subnet-mask 255.255.255.255;
#}
#lease {
# interface "wlan0";
# fixed-address 192.168.0.108;
# medium "link0 link1";
# option host-name "banan.dev";
# option subnet-mask 255.255.255.0;
# option broadcast-address 192.33.137.255;
# option routers 192.168.0.1;
# option domain-name-servers 127.0.0.1;
# renew 2 2000/1/12 00:00:01;
# rebind 2 2000/1/12 00:00:01;
# expire 2 2000/1/12 00:00:01;
#}
host bananapim2zero {
hardware ethernet ac:6a:a3:27:8a:e1;
fixed-address 192.168.0.108;
}
send host-name "bananapim2zero"; # added by NetworkManager
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
option ms-classless-static-routes code 249 = array of unsigned integer 8;
option wpad code 252 = string;
request; # override dhclient defaults
also request subnet-mask;
also request broadcast-address;
also request time-offset;
also request routers;
also request domain-name;
also request domain-name-servers;
also request domain-search;
also request host-name;
also request dhcp6.name-servers;
also request dhcp6.domain-search;
also request dhcp6.fqdn;
also request dhcp6.sntp-servers;
also request netbios-name-servers;
also request netbios-scope;
also request interface-mtu;
also request rfc3442-classless-static-routes;
also request ntp-servers;
also request ms-classless-static-routes;
also request static-routes;
also request wpad;
also request root-path;
这意味着NetworkManager
应该使用它dhclient
,因为它是 DHCP 后端,并且我已在其配置中添加了用于修复(但我想要保留,这样如果不可用则不会失败)的部分(可能是错误的部分)地址。不工作;记录得很差。
操作系统:armbian最新
提前致谢