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