当前位置: 首页 > 工具软件 > Wicked Shell > 使用案例 >

openSUSE 管理无线网络(networkManager/wicked/iwconfig)

满言
2023-12-01

1、列出无线网络接口和无线信息

iwconfig
#主要显示无线网络接口为wlp3s0,及其支持的信息,或已连接的信息
hybian@linux-jsrn:/> /usr/sbin/iwconfig
wlp3s0    IEEE 802.11  ESSID:"My_Girl*Love*_1031"  
          Mode:Managed  Frequency:5.765 GHz  Access Point: C4:A8:1D:8D:44:CA   
          Bit Rate=6 Mb/s   Tx-Power=30 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=65/70  Signal level=-45 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:9  Invalid misc:45   Missed beacon:0

lo        no wireless extensions.

enp2s0    no wireless extensions.

vboxnet0  no wireless extensions.

hybian@linux-jsrn:/>

2、停用,启用wlan0无线网络接口

sudo ip link set wlp3s0 down | up

3、在可用无线网络接口下扫描可用的Wi-Fi

sudo iwlist wlp3s0 scan

创建连接配置文件

#新建一个临时目录
sudo mkdir /tmp/wifi
#新建wifi配置文件
sudo vi /tmp/wifi/wifi.cnf
#将以下模板配置改为自己的配置

 ctrl_interface=/tmp/wifi/iface

 network={
     ssid="eXample"
     key_mgmt=WPA-PSK
     proto=WPA
     pairwise=TKIP
     group=TKIP
     psk="$your_password"
 }

#保存后退出

4、应用新的网络配置


 /usr/sbin/wpa_supplicant -B -c/tmp/wifi/wifi.conf -iwlp3s0

5、检查应用的配置

iwconfig

 lo     no wireless extensions.

 eth0   no wireless extensions.

 wlan0  IEEE 802.11g  ESSID:"eXample"
        Mode: Managed  Channel:3 Access Point: AA:BB:CC:00:11:22
        Retry min limit: 7  RTS thr: off  Fragment thr: 2346 B
        Encryption key:$some_very_long_key ;)
        Link quality:90/100  Signal level:-59dBm

动态IP或静态IP

sudo vim /etc/sysconfig/network/ifcfg-wlp3s0
#BOOTPROTO='dhcp'
BOOTPROTO='static'
BROADCAST=''
DHCLIENT_SET_DEFAULT_ROUTE='yes'
ETHTOOL_OPTIONS=''
IFPLUGD_PRIORITY='0'
IPADDR='10.6.161.96'
MTU=''
NAME='QCA6164 802.11ac Wireless Network Adapter'
NETMASK='255.255.255.0'
NETWORK=''
GATEWAY='10.6.161.1'
REMOTE_IPADDR=''
STARTMODE='auto'
WIRELESS_AP=''
WIRELESS_AP_SCANMODE='1
WIRELESS_AUTH_MODE='psk'
WIRELESS_BITRATE='auto'
WIRELESS_CA_CERT=''
WIRELESS_CHANNEL=''
WIRELESS_CLIENT_CERT=''
WIRELESS_CLIENT_KEY=''
WIRELESS_CLIENT_KEY_PASSWORD=''
WIRELESS_DEFAULT_KEY='0'
WIRELESS_EAP_AUTH=''
WIRELESS_EAP_MODE=''
WIRELESS_ESSID='XXXXXXXXXXXXXXXXXXXXXXXXX'
WIRELESS_FREQUENCY=''
WIRELESS_KEY=''
WIRELESS_KEY_0=''
WIRELESS_KEY_1=''
WIRELESS_KEY_2=''
WIRELESS_KEY_3=''
WIRELESS_KEY_LENGTH='128'
WIRELESS_MODE='Managed'
WIRELESS_NICK=''
WIRELESS_NWID=''
WIRELESS_PEAP_VERSION=''
WIRELESS_POWER='no'
WIRELESS_WPA_ANONID=''
WIRELESS_WPA_IDENTITY=''
WIRELESS_WPA_PASSWORD=''
WIRELESS_WPA_PSK='XXXXXXXXXXXXXXXXXXX'

注意: 在考虑配置静态dns的时候,可以直接在/etc/sysconfig/network/ifcfg-wlp3s0 文件中添加 NETCONFIG_DNS_STATIC_SERVERS=’192.168.1.1’ ;
如果希望在/etc/resolv.conf 中静态配置nameserver 192.168.1.1,则必须先在/etc/sysconfig/network/ifcfg-wlp3s0中添加NETCONFIG_DNS_POLICY=” 配置字段,将netconfig 通过ifcfg-wlp3s0更新dns 的功能禁用。

查看网络连接状态

ip address show wlp3s0
 类似资料: