首页 > 代码库 > Ubuntu 下配置无线网络

Ubuntu 下配置无线网络

Ubuntu环境下,配置无线网络,下面是一个脚本:

#!/bin/sh

set -e
NETWORK_INTERFACE="/etc/network/interfaces"
WIFI_CONFIG="/etc/wifi_config.conf"

if [ $# -ne 2 ]
then
	echo "input parameters number error"
	echo "example:"
	echo "wifi_setting.sh wifi_ID wifi_passwd"
	exit
fi

WIFI_USERNAME=$1
WIFI_PASSWD=$2

/usr/bin/wpa_passphrase ${WIFI_USERNAME} ${WIFI_PASSWD} >${WIFI_CONFIG}

if [ $? -eq 0 ]
then
	echo "set wifi ID passwd successful"
else
	echo "set wifi ID passwd failed."
	exit
fi

echo "auto wlan0" > ${NETWORK_INTERFACE}
echo "iface wlan0 inet dhcp" >> ${NETWORK_INTERFACE}
echo "wpa-conf ${WIFI_CONFIG} " >> ${NETWORK_INTERFACE}
reboot

参考资料

1、NetworkManager——Linux强大的网络管理工具

2、http://blog.csdn.net/secondjanuary/article/details/8980228 

Ubuntu 下配置无线网络