我家里有孩子,我需要找到一种根据登录者启动 wifi 连接的方法:
- kids => 使用接入点 ssid: CHILD
- 成人 => 使用接入点 ssid:成人
Lubuntu 12.04 LTS
谨此致以问候并提前感谢您的帮助。
答案1
我终于自己找到了:
1- 以root身份登录:
sudo su -
2- 为每个用户在其主目录中创建自动启动目录
mkdir -p /home/USERNAME/.config/autostart
3- 将以下代码复制到系统每个用户的自动启动目录中的 network.desktop 文件中
[Desktop Entry]
Name=demarrage
Comment=Manage your network connections
Exec=/usr/local/bin/dhclient-util.sh
Type=Application
NoDisplay=true
4-将以下代码复制到 /etc/local/bin/dhclient-util.sh
#!/bin/sh
##################################################################
# dhclient-util.sh
# script shell pour changer le fichier /etc/dhcpd/dhclient.conf
# pour y ajouter selon l util le dns de opendns
#
# entree: neant
#
# sortie: 0
#
# auteur: yves guerin (C) 2012 [email protected]
#
# version:
# 0.0.1 : yguerin - 2012-12-12 : initiale
#################################################################
# prog
CP=`which cp`
GREP=`which grep`
NMCLI=`which nmcli`
SLEEP=`which sleep`
SUDO=`which sudo`
# var
DELAI="2"
TYPEUTIL="enfant"
# verif dans quelle liste se trouve l`utilisateur
RET=`${GREP} -w ${USER} /etc/dhcp/enfant.list`
# verif si vide
if [ ${#RET} -eq 0 ] ; then
# vide, verif dans l`autre liste
RET=`${GREP} -w ${USER} /etc/dhcp/parent.list`
# verif si non vide
if [ ${#RET} -gt 0 ] ; then
# trouve
TYPEUTIL="parent"
fi
fi
# arrete toute les connexions reseau
${NMCLI} nm enable false
case ${TYPEUTIL} in
"parent" )
# copie dhclient.conf pour adulte
${SUDO} ${CP} -f /etc/dhcp/dhclient.conf.defaut /etc/dhcp/dhcli$
;;
* )
# sinon pour les autres dhclient.conf enfant opendns
${SUDO} ${CP} -f /etc/dhcp/dhclient.conf.enfant /etc/dhcp/dhcli$
;;
esac
# attente
# attente
${SLEEP} ${DELAI}
# redemarre le reseau
${NMCLI} nm enable true
exit 0
5-使其可执行
chmod gu+x /etc/local/bin/dhclient-util.sh
6-创建用户列表并输入用户名
touch /etc/dhcp/parent.list
echo joe >> /etc/dhcp/parent.list
touch /etc/dhcp/enfant.list
echo sophie >> /etc/dhcp/enfant.list
7- 为每个列表创建一个包含所需选项的 dhclient.conf 文件(参见 dhclient-util.sh)
enfant.list => /etc/dhcp/dhclient.enfant.conf
parent.list => /etc/dhcp/dhclient.conf.defaut
8- 对于 opendns 域名服务器 ip,我在 /etc/dhcp/dhclient.conf.enfant 中添加了以下行
supersede domain-name-servers 208.67.222.222, 208.67.220.220;
9-从同一文件中删除“请求”中的“域名服务器”一词
就是这样 :)
在笔记本电脑上有用。
左心室