Common commands for connecting wireless networks under Linux

Source: Internet
Author: User

Enable/restart/shutdown network services

/etc/init.d/networking start

/etc/init.d/networking restart

/etc/init.d/networking stop

Among them, networking is the name under Ubuntu, other systems have different names, such as OpenWrt called Network.

 

Enable/Disable the wireless card Wlan0 (also known as Ath0, customizable):

Ifdown Wlan0

Equivalent to Ifconfig wlan0 down

Ifup Wlan0

Equivalent to ifconfig wlan0 up

Scanning

Scan WLAN:

Iwlist scaning | More #iwlist是一个很好的命令, can scan the SSID, channel and other quantities

(different from IW list)

Set Wlan0:

Set the AP Name

Iwconfig wlan0 Essid "SSID"

Iwconfig Wlan0 Essid SSID

Iwconfig Wlan0 Essid-"any" (if the SSID has any,no, or off, preceded by "--")

Iwconfig Wlan0 Essid any

Iwconfig Wlan0 Essid off

But if the wireless network has encryption, it is more troublesome. The methods for AES, WPA, and WPA2 are different.

Wep:

Iwconfig wlan0 ESSID XXX key s:xxx

or by modifying/etc/network/interfaces, this configuration file is a variety of (optional) configuration of the NIC interface:

Iface eth0 inet Static

Address XX. Xx. Xx. Xx

Netmask XX. Xx. Xx. Xx

Gateway XX. Xx. Xx.1

Wireless-essid XXX

Wireless-key XXX

WPA/WPA2:

wpa_passphrase [ESSID] [password] >> <some path/xxx.conf> #这会由你输入的ESSID和密码形成一段结构化的文本, network{essid= ..... , }

Wap_supplicant-i wlan0-c <some path/xxx.conf>-D wext-b

Get address automatically

Dhclient Wlan0 (If an Ethernet port: dhclient eth0), a DHCP request is issued to the set SSID

Set Static Address

Iwconfig wlan0 XXX.XXX.XXX.XXX netmask XX. Xx. Xx. Xx

Add a static route (if the IP address is not a problem, you can also ping the IP of the must have plotted network segment but ping the host on the gateway, then check the route and DNS)

Route add default GW [gateway address] that is, all packages are forwarded through the gateway (since notebooks generally have only one gateway for egress)

Route add-net [Destip] netmask [netmask] Dev [interface] (see Man route)

Add/Modify DNS:

The DNS address is written in a configuration file:/etc/resolv.conf, modify it

Common commands for connecting wireless networks under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.