zoukankan      html  css  js  c++  java
  • wifi--wpa_supplicant

    Linux命令行连接wifi--wpa_supplicant

    https://wiki.gentoo.org/wiki/Handbook:AMD64/Networking/Wireless
    CentOS7为例:
    先启用无线网卡再扫描wifi信号
    root@jlive:~#ip link set wlp3s0 up
    root@jlive:~#iw dev wlp3s0 scan|grep wifi


    A.WPA/WPA2加密
    root@jlive:~#vim /etc/sysconfig/wpa_supplicant
    network={
            ssid="wifi"
            psk="foo.123"
            priority=1
    }
    root@jlive:~#wpa_supplicant -i wlp3s0 -c /etc/sysconfig/wpa_supplicant
    Successfully initialized wpa_supplicant
    wlp3s0: Trying to associate with ec:26:ca:67:0b:fe (SSID='rukawa' freq=2437 MHz)
    ioctl[SIOCSIWFREQ]: Device or resource busy
    wlp3s0: Association request to the driver failed
    wlp3s0: Associated with ec:26:ca:67:0b:fe
    wlp3s0: WPA: Key negotiation completed with ec:26:ca:67:0b:fe [PTK=CCMP GTK=CCMP]
    wlp3s0: CTRL-EVENT-CONNECTED - Connection to ec:26:ca:67:0b:fe completed [id=0 id_str=]
    看到这个提示,应该感到非常兴奋,成功连接
    root@jlive:~#ifconfig wlp3s0
    wlp3s0: flags=4163  mtu 1500
            inet6 fe80::466d:57ff:feb3:a7e5  prefixlen 64  scopeid 0x20
            ether 44:6d:57:b3:a7:e5  txqueuelen 1000  (Ethernet)
            RX packets 2  bytes 282 (282.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 10  bytes 1096 (1.0 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    再看下是否拿到IP,发现没有,所以还差一步,主动发起DHCP请求地址
    root@jlive:~#dhclient wlp3s0
    root@jlive:~#ifconfig wlp3s0
    wlp3s0: flags=4163  mtu 1500
            inet 192.168.100.108  netmask 255.255.255.0  broadcast 192.168.100.255
            inet6 fe80::466d:57ff:feb3:a7e5  prefixlen 64  scopeid 0x20
            ether 44:6d:57:b3:a7:e5  txqueuelen 1000  (Ethernet)
            RX packets 2885  bytes 2092956 (1.9 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 2708  bytes 488745 (477.2 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    B.wep加密
    https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Networking

    For most users, there are only two settings that might be important to change, the ESSID (aka wireless network name) or the WEP key. If the ESSID and Access Point address listed are already those of the environment's access point and the environment is not not using WEP, then the wireless configuration is already working.

    To change the ESSID, or add a WEP key, issue the following commands.

    • To set the network name to GentooNode:
    root #iwconfig eth0 essid GentooNode
    • To set a hex WEP key:
    root #iwconfig eth0 key 1234123412341234abcd

    To set an ASCII WEP key, prefix the key with s::

    root #iwconfig eth0 key s:some-password
    或者 
    root #iwconfig eth0 key s:some-password
    root@jlive:~#iw dev wlp3s0 connect "wifi名" key 0:密码
    root@jlive:~#dhclient wlp3s0

  • 相关阅读:
    SpringBoot-redis-session
    设计模式总结
    linux 查看磁盘信息
    MAC配置JAVA环境变量
    mysql设计规范二
    mysql设计规范一
    Alibaba 镜像
    ELK之Logstash配置文件详解
    Docker 搭建 ELK 读取微服务项目的日志文件
    SpringBoot 读取配置文件的值 赋给静态变量
  • 原文地址:https://www.cnblogs.com/lixuebin/p/10814413.html
Copyright © 2011-2022 走看看