Centos7 连接无线网wifi
笔记本在裸机情况下没有ficonfig、iw、nmcli等软件,没有网线仅有网卡,此时只有通过wpa_supplicant来连接wifi。
无线网卡开启
- 查看网卡设备号(Device)
ip addr
- 查看无线网卡是否激活
ip link show wlp18s0b1
- 激活无线网卡
ip link set wlp18s0b1 up
- 连接网卡
# ssid-无线网络名称 pwd-无线网密码 wpa_supplicant -B -i wlp18s0b1 -c <(wpa_passphrase "ssid" "pwd")
- 动态获取IP
# 如果动态获取IP失败 # systemctl stop NetworkManager # systemctl disable NetworkManager # reboot dhclient wlp18s0b1
- 查看IP
ip addr show wlp18s0b1
将wifi改为静态IP
- 获取NETMASK
# 如果ifconfig没有 # yum -y install net-tools ifconfig
- 获取DNS
cat /etc/resolv.conf
- 获取GATEWAY
netstat -rn
- 通过图形界面生成ifcfg-wlp18s0b1和keys-wlp18s0b1
nmtui
- 修改ifcfg-wlp18s0b1
cd /etc/sysconfig/network-scripts/ vim ifcfg-wlp18s0b1 # ifcfg-wlp18s0b1 ESSID=ssid MODE=Managed KEY_MGMT=WPA-PSK MAC_ADDRESS_RANDOMIZATION=default TYPE=Wireless PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=static DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=wlp18s0b1 UUID=6e1d4b65-1669-4a6d-82aa-f92c87cdf4a6 DEVICE=wlp18s0b1 ONBOOT=yes IPADDR=192.168.101.29 NETMASK=255.255.255.0 DNS1=192.168.101.1 GATEWAY=192.168.101.1
- 启动/停止/重启网络服务或者重启
service network stop/start/restart
网络状态查看
# Ensure that your device is included in the INTERFACES line in this file. vi /etc/sysconfig/wpa_supplicant # 查看无线网接口(Interface) iw dev # 查看接口连接信息 iw wlp3s0 link # 查看网络接口/网卡状态 ip addr ip link # 查看周围wifi iw dev wlp18s0b1 scan | grep SSID