linux 尝试连接 wifi 问题

由于实际应用需求,linux客户端处于环线运行,有可能在某个角落无法连接上wifi,因此在断网时需要一直不断尝试连接wifi。
本人原先使用如下命令进行连接

udhcpc -i wlan0

实际效果是,如果没连接到wifi,则每隔2秒连接1次,尝试3次,然后隔20秒再重新连接,然后重复之前动作。
实际的意思是该命令执行3次请求,3次没成功则算失败,失败后过20秒重启这个命令。

为了保证能一直不间断的尝试,可以使用如下命令

udhcpc -b -i wlan0 -t 1 -A 2

-b 表示命令执行失败后进入后台执行
-t 1 表示命令执行请求1次
-A 表示命令执行失败后重启的时间间隔设为2秒
udhcpc 其他参数见如下

udhcpc

udhcpc [-Cfbnqtvo] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE] [-p pidfile] [-r IP] [-s script] [-O dhcp-option]... 

        -V,--vendorclass=CLASSID        Vendor class identifier
        -i,--interface=INTERFACE        Interface to use (default eth0)
        -H,-h,--hostname=HOSTNAME       Client hostname
        -c,--clientid=CLIENTID  Client identifier
        -C,--clientid-none      Suppress default client identifier
        -p,--pidfile=file       Create pidfile
        -r,--request=IP         IP address to request
        -s,--script=file        Run file at DHCP events (default /usr/share/udhcpc/default.script)
        -t,--retries=N          Send up to N request packets
        -T,--timeout=N          Try to get a lease for N seconds (default 3)
        -A,--tryagain=N         Wait N seconds (default 20) after failure
        -O,--request-option=OPT Request DHCP option OPT (cumulative)
        -o,--no-default-options Do not request any options (unless -O is also given)
        -f,--foreground Run in foreground
        -b,--background Background if lease is not immediately obtained
        -S,--syslog     Log to syslog too
        -n,--now        Exit with failure if lease is not immediately obtained
        -q,--quit       Quit after obtaining lease
        -R,--release    Release IP on quit
        -a,--arping     Use arping to validate offered address

udhcpc 属于 BusyBox 的内容

你可能感兴趣的:(linux 尝试连接 wifi 问题)