我有一个 udev 事件,当插入网络适配器时,运行 dhclient 来分配一个 IP,我想分配一个 IPv4,但它总是给我 IPv6 地址(我不想要,当我从命令行运行 dhclient 时它总是给我 IPv4 地址),这是我的规则:
ACTION=="add", SUBSYSTEM=="net",KERNELS!="eth0",KERNELS=="eth*",RUN+="/usr/sbin/dhclient -4 %k"
结果如下:
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 2a02:a03f:6080:7200:9c9:73cd:af73:652 prefixlen 64 scopeid 0x0<global>
inet6 2a02:a03f:6080:7200:215:5dff:fe01:25d5 prefixlen 64 scopeid 0x0<global>
inet6 fe80::215:5dff:fe01:25d5 prefixlen 64 scopeid 0x20<link>
ether 00:15:5d:01:25:d5 txqueuelen 1000 (Ethernet)
RX packets 167 bytes 43826 (43.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10 bytes 888 (888.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
我在 WSL2 Ubuntu 22.04 上运行