我正在尝试使用连接到我的 wifi 网络的 busybox 创建一个最小的 Linux initramfs 环境。 wpa_supplicant
成功初始化,但 udhcpc 和设置静态 IP 地址均不起作用。这些是使用的命令:
$ # Mount /dev, /proc, and /sys
$ mount -t devtmpfs none /dev
$ mount -t proc none /proc
$ mount -t sysfs none /sys
$ # Modprobe the required drivers
$ modprobe rfkill
$ modprobe cfg80211
$ modprobe 8723cs
$ # Set up wpa_supplicant
$ ip link set dev wlan0 up
$ wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
$ # Attempt to get an IP address...
$ udhcpc -i wlan0
udhcpc: sending discover
udhcpc: sending discover
udhcpc: sending discover
...
udhcpc 从不接收 IP 地址。我也尝试过手动设置 IP 地址,但这也不起作用。这是该命令的 strace 输出:timeout 15 strace /bin/busybox udhcpc -i wlan0
execve("/bin/busybox", ["/bin/busybox", "udhcpc", "-i", "wlan0"], 0x7fe700f4e8 /* 4 vars */) = 0
brk(NULL) = 0x5e9000
brk(0x5e9fb0) = 0x5e9fb0
uname({sysname="Linux", nodename="(none)", ...}) = 0
readlinkat(AT_FDCWD, "/proc/self/exe", "/bin/busybox", 4096) = 12
brk(0x60afb0) = 0x60afb0
brk(0x60b000) = 0x60b000
mprotect(0x5dc000, 28672, PROT_READ) = 0
prctl(PR_SET_NAME, "busybox") = 0
getuid() = 0
openat(AT_FDCWD, "/dev/null", O_RDWR) = 3
close(3) = 0
pipe2([3, 4], 0) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fcntl(4, F_SETFD, FD_CLOEXEC) = 0
fcntl(3, F_GETFL) = 0 (flags O_RDONLY)
fcntl(3, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
fcntl(4, F_GETFL) = 0x1 (flags O_WRONLY)
fcntl(4, F_SETFL, O_WRONLY|O_NONBLOCK) = 0
rt_sigaction(SIGUSR1, {sa_handler=0x4527e8, sa_mask=[USR1], sa_flags=SA_RESTART}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGUSR2, {sa_handler=0x4527e8, sa_mask=[USR2], sa_flags=SA_RESTART}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGTERM, {sa_handler=0x4527e8, sa_mask=[TERM], sa_flags=SA_RESTART}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
socket(AF_INET, SOCK_RAW, IPPROTO_RAW) = 5
ioctl(5, SIOCGIFINDEX, {ifr_name="wlan0", }) = 0
ioctl(5, SIOCGIFHWADDR, {ifr_name="wlan0", ifr_hwaddr={sa_family=ARPHRD_ETHER, sa_data=02:ba:cc:bb:c0:78}}) = 0
close(5) = 0
write(2, "udhcpc: started, v1.32.0\n", 25udhcpc: started, v1.32.0
) = 25
gettimeofday({tv_sec=16, tv_usec=410401}, NULL) = 0
clone(child_stack=0x7ff9a7cad0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 136
wait4(136, Clearing IP addresses on wlan0, upping it
[{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 136
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=136, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)) = 5
bind(5, {sa_family=AF_PACKET, sll_protocol=htons(ETH_P_IP), sll_ifindex=if_nametoindex("wlan0"), sll_hatype=ARPHRD_NETROM, sll_pkttype=PACKET_HOST, sll_halen=0}, 20) = 0
setsockopt(5, SOL_PACKET, PACKET_AUXDATA, [1], 4) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
socket(AF_INET, SOCK_RAW, IPPROTO_RAW) = 6
ioctl(6, SIOCGIFINDEX, {ifr_name="wlan0", }) = 0
ioctl(6, SIOCGIFHWADDR, {ifr_name="wlan0", ifr_hwaddr={sa_family=ARPHRD_ETHER, sa_data=02:ba:cc:bb:c0:78}}) = 0
close(6) = 0
write(2, "udhcpc: sending discover\n", 25udhcpc: sending discover
) = 25
socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)) = 6
bind(6, {sa_family=AF_PACKET, sll_protocol=htons(ETH_P_IP), sll_ifindex=if_nametoindex("wlan0"), sll_hatype=ARPHRD_NETROM, sll_pkttype=PACKET_HOST, sll_halen=6, sll_addr=[0xff, 0xff, 0xff, 0xff, 0xff, 0xff]}, 20) = 0
sendto(6, "E\0\1H\0\0\0\0@\21y\246\0\0\0\0\377\377\377\377\0D\0C\0014\331C\1\1\6\0"..., 328, 0, {sa_family=AF_PACKET, sll_protocol=htons(ETH_P_IP), sll_ifindex=if_nametoindex("wlan0"), sll_hatype=ARPHRD_NETROM, sll_pkttype=PACKET_HOST, sll_halen=6, sll_addr=[0xff, 0xff, 0xff, 0xff, 0xff, 0xff]}, 20) = 328
close(6) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
ppoll([{fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 2, {tv_sec=3, tv_nsec=0}, NULL, 0) = 0 (Timeout)
socket(AF_INET, SOCK_RAW, IPPROTO_RAW) = 6
ioctl(6, SIOCGIFINDEX, {ifr_name="wlan0", }) = 0
ioctl(6, SIOCGIFHWADDR, {ifr_name="wlan0", ifr_hwaddr={sa_family=ARPHRD_ETHER, sa_data=02:ba:cc:bb:c0:78}}) = 0
close(6) = 0
write(2, "udhcpc: sending discover\n", 25udhcpc: sending discover
) = 25
socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)) = 6
bind(6, {sa_family=AF_PACKET, sll_protocol=htons(ETH_P_IP), sll_ifindex=if_nametoindex("wlan0"), sll_hatype=ARPHRD_NETROM, sll_pkttype=PACKET_HOST, sll_halen=6, sll_addr=[0xff, 0xff, 0xff, 0xff, 0xff, 0xff]}, 20) = 0
sendto(6, "E\0\1H\0\0\0\0@\21y\246\0\0\0\0\377\377\377\377\0D\0C\0014\331@\1\1\6\0"..., 328, 0, {sa_family=AF_PACKET, sll_protocol=htons(ETH_P_IP), sll_ifindex=if_nametoindex("wlan0"), sll_hatype=ARPHRD_NETROM, sll_pkttype=PACKET_HOST, sll_halen=6, sll_addr=[0xff, 0xff, 0xff, 0xff, 0xff, 0xff]}, 20) = 328
close(6) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
ppoll([{fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 2, {tv_sec=3, tv_nsec=0}, NULL, 0) = 0 (Timeout)
socket(AF_INET, SOCK_RAW, IPPROTO_RAW) = 6
ioctl(6, SIOCGIFINDEX, {ifr_name="wlan0", }) = 0
ioctl(6, SIOCGIFHWADDR, {ifr_name="wlan0", ifr_hwaddr={sa_family=ARPHRD_ETHER, sa_data=02:ba:cc:bb:c0:78}}) = 0
close(6) = 0
write(2, "udhcpc: sending discover\n", 25udhcpc: sending discover
) = 25
socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_IP)) = 6
bind(6, {sa_family=AF_PACKET, sll_protocol=htons(ETH_P_IP), sll_ifindex=if_nametoindex("wlan0"), sll_hatype=ARPHRD_NETROM, sll_pkttype=PACKET_HOST, sll_halen=6, sll_addr=[0xff, 0xff, 0xff, 0xff, 0xff, 0xff]}, 20) = 0
sendto(6, "E\0\1H\0\0\0\0@\21y\246\0\0\0\0\377\377\377\377\0D\0C\0014\331=\1\1\6\0"..., 328, 0, {sa_family=AF_PACKET, sll_protocol=htons(ETH_P_IP), sll_ifindex=if_nametoindex("wlan0"), sll_hatype=ARPHRD_NETROM, sll_pkttype=PACKET_HOST, sll_halen=6, sll_addr=[0xff, 0xff, 0xff, 0xff, 0xff, 0xff]}, 20) = 328
close(6) = 0
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
ppoll([{fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 2, {tv_sec=3, tv_nsec=0}, NULL, 0) = 0 (Timeout)
socket(AF_INET, SOCK_RAW, IPPROTO_RAW) = 6
ioctl(6, SIOCGIFINDEX, {ifr_name="wlan0", }) = 0
ioctl(6, SIOCGIFHWADDR, {ifr_name="wlan0", ifr_hwaddr={sa_family=ARPHRD_ETHER, sa_data=02:ba:cc:bb:c0:78}}) = 0
close(6) = 0
clone(child_stack=0x7ff9a7cad0, flags=CLONE_VM|CLONE_VFORK|SIGCHLD) = 140
wait4(140, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 140
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=140, si_uid=0, si_status=0, si_utime=0, si_stime=0} ---
fcntl(5, F_SETFD, FD_CLOEXEC) = 0
ppoll([{fd=3, events=POLLIN}, {fd=5, events=POLLIN}], 2, {tv_sec=20, tv_nsec=0}, NULL, 0strace: Process 135 detached
udhcpc: received SIGTERM
<detached ...>
Terminated