[图文]Ubuntu的802.1x解决方案:Xsupplicant

来源:互联网 发布:程序员与架构师 编辑:程序博客网 时间:2024/06/07 06:52
** stlxv原创文章,转载请注明出处 **
** 平台:Ubuntu 7.04 Desktop
** 实例:锐捷校园网解决方案

Ubuntu的802.1x解决方案:Xsupplicant



前言

    目前,国内已有不少网络提供商用802.1x协议作为网络接入的认证方式。特别在一些高校和一些无线网络中更是常见。Xsupplicant是一个通用的跨平台802.1x客户端解决方案。使用Xsupplicant,可以很容易地进行802.1x协议认证。锐校园网是一个802.1x认证的实例。本文将首先介绍Xsupplicant在Ubuntu中的安装,接着以接入锐校园网为例子,介绍在Ubuntu中Xsupplicant的设置与使用。


下载与安装

    Xsupplicant已经包含在Ubuntu的官方universe源里面,因此可以从新立得软件包管理器方便地从Ubuntu官方的universe源里面下载安装。如图所示。


    若不能通过新立得软件包管理器来安装,可以从官方源(或官方源的镜像站点)的网站下载Xsupplicant的deb包进行安装,它往往可以在官方源的./pool/universe/x/xsupplicant目录下找到。例如源的地址是http://ftp.sjtu.edu.cn/ubuntu/(注:这是ubuntu官方源的一个教育网镜像,其他官方源或其镜像亦可),那么Xsupplicant可以在http://ftp.sjtu.edu.cn/ubuntu/./pool/universe/x/xsupplicant/下载到。首先进入到http://ftp.sjtu.edu.cn/ubuntu/./pool/universe/x/xsupplicant/,接着根据自己的机器情况选择合适的Xsupplicant版本的deb包进行下载。这里下载xsupplicant_1.2.4.dfsg.1-1_i386.deb文件。其中,xsupplicant是软件包的名字,1.2.4.dfsg.1是软件包的版本,1是ubuntu内部维护的版本号,i386是指该文件所适用硬件的平台:Intel 32位CPU。所有文件的命名均遵循同一种命名格式。倘若不知道下载哪个才对,就把所有的deb包都下载回来,总有一个是对的。

    获得xsupplicant的deb包之后,安装变得十分简单。首先双击下载回来的deb包,打开“软件包安装”对话框,如图所示。


单击“安装软件包”按钮,输入密码后开始安装Xsupplicant,如图所示。


当屏幕显示如下图所示时,整个安装过程便已结束。单击“关闭”按钮,关闭窗口。


    下面将以怎样通过锐杰校园网802.1x验证为例子,介绍Xsupplicant的使用方法。


实例:锐捷校园网解决方案

    锐捷校园网802.1x解决方案由于使用802.1x进行用户认证,因此可以用Xsupplicant作为认证客户端。Xrgsu是锐捷官方提供的Linux认证客户端,然而笔者个人感觉用Xsupplicant比用Xrgsu更稳定、更简单。另外,使用Xsupplicant会获得更好的支持。

设置

     在Ubuntu中,Xsupplicant使用两个配置文件,分别是/etc/xsupplicant/xsupplicant.conf和/etc/default/xsupplicant。其中,文件/etc/xsupplicant/xsupplicant.conf用于Xsupplicant的功能配置,而文件/etc/default/xsupplicant则记录Ubuntu如何控制Xsupplicant的行为。

    首先通过配置/etc/xsupplicant/xsupplicant.conf文件来设置上网的用户名和密码。按下键盘上的Alt+F2,打开“运行应用程序”窗口。在下拉文本框中输入“gksu gedit /etc/xsupplicant/xsupplicant.conf”(当然,可以单击“带文件运行”按钮来简化输入),如图所示。


单击“运行”按钮,输入密码后,文本编辑器将会打开/etc/xsupplicant/xsupplicant.conf以便进行编辑。如图所示。


如图所示为/etc/xsupplicant/xsupplicant.conf的内容。其中,从符号“#”开始到当行结束的部分,称为“注释”,用于详细说明文件中各个部分的内容。计算机并不理会注释,因而注释可以被自由地更改、添加、删除。在该文件中,找到default节。default节由“default”开头以及后面所接的一对大括号以及该对大括号里面的内容所组成。默认的default节没有内容,所以可能为“default {}”。一个默认的default节可能是这样(注:这个default节里并没有内容,default节上面以“#”开头的部分为注释,可以不用理会):

## Default Network Section
#
 This is the network configuration that will be used in the event that
#
 no valid network configuration can be found.  If you are going to leave
#
 Xsupplicant running all the time, it is recommended that you leave this
#
 section blank.  A blank network definition will result in Xsupplicant 
#
 turning off encryption and turning control over to iwconfig.
default
{
}

接下来将为default节增加内容,以使Xsupplicant可以顺利地通过锐杰认证。(注:关于该文件的具体配置方法以及各部分的意义和使用说明,请参阅文件具体内容,以及Xsupplicant的说明文档)

    为default节添加内容,结果如下所示。

## Default Network Section
#
 This is the network configuration that will be used in the event that
#
 no valid network configuration can be found.  If you are going to leave
#
 Xsupplicant running all the time, it is recommended that you leave this
#
 section blank.  A blank network definition will result in Xsupplicant 
#
 turning off encryption and turning control over to iwconfig.
default
{
    allow_types 
= eap-md5
    identity 
= "your_username"
    eap
-md5 {
              username 
= "your_username"
              password 
= "your_password"
    }
}

其中,双引号中的“your_username”为读者上网的帐号,双引号中的“your_password”为读者上网的密码。请根据自己的具体情况作相应的改变。假设读者的上网帐号为abc,密码为12345,则更改后的default节如下所示。

## Default Network Section
#
 This is the network configuration that will be used in the event that
#
 no valid network configuration can be found.  If you are going to leave
#
 Xsupplicant running all the time, it is recommended that you leave this
#
 section blank.  A blank network definition will result in Xsupplicant 
#
 turning off encryption and turning control over to iwconfig.
default
{
    allow_types 
= eap-md5
    identity 
= "abc"
    eap
-md5 {
              username 
= "abc"
              password 
= "12345"
    }
}

为完成对/etc/xsupplicant/xsupplicant.conf的更改,单击“保存”按钮,保存所做的修改。至此,Xsupplicant的配置已经完成。接下来将修改/etc/default/xsupplicant文件,以启用Xsupplicant。
单击“打开”按钮,在“打开文件...”对话框中,找到/etc/default/xsupplicant文件,单击“打开”按钮打开该文件以编辑。

    默认的/etc/default/xsupplicant文件可能如下所示。

# /etc/default/xsupplicant

# WARNING! Before enabling xsupplicant, make sure you have a valid 
#
 configuration file, (/etc/xsupplicant/xsupplicant.conf), and that
#
 you have set a list of arguments below.
ENABLED=0

# At a minimum you need to set an interface with the -i argument. See 
#
 the man page xsupplicant(8) for more options and information.
#
ARGS="-i wlan0 -s"

# EXAMPLES:

# ARGS="-i eth1 -D hostap -c /etc/xsupplicant/xsupplicant.conf"
#
 ARGS="-i wlan0 -z"

跟/etc/xsupplicant/xsupplicant.conf相似,以“#”开头到行末的部分为注释,并不被计算机所处理,可以任意更改。在该文件中,将“ENABLED=0”改成“ENABLED=1”,接着在文件中新增加一行,内容为“ARGS="-i eth0"”(这里假设用于锐认证的网卡为/dev/eth0,也就是第一块网卡;若不是第一块网卡,或者是无线网卡,请根据具体情况作相应更改),更改后的文件内容可能如下。

# /etc/default/xsupplicant

# WARNING! Before enabling xsupplicant, make sure you have a valid 
#
 configuration file, (/etc/xsupplicant/xsupplicant.conf), and that
#
 you have set a list of arguments below.
ENABLED=1

# At a minimum you need to set an interface with the -i argument. See 
#
 the man page xsupplicant(8) for more options and information.
#
ARGS="-i wlan0 -s"
ARGS="-i eth0"

# EXAMPLES:

# ARGS="-i eth1 -D hostap -c /etc/xsupplicant/xsupplicant.conf"
#
 ARGS="-i wlan0 -z"

单击“保存”按钮,保存所作的修改。重新启动计算机后,Xsupplicant将自动启动并自动执行验证。

启用与关闭

    在计算机启动后,Xsupplicant将会自动启动。Xsupplicant启动后,若要关闭Xsupplicant:

  1. 按Alt+F2打开运行应用程序对话框。

  2. 在下拉文本框中输入“gksu /etc/init.d/xsupplicant stop”,单击“运行”按钮,输入密码后,Xsupplicant就自动关闭了。

此时若想启动Xsupplicant:

  1. 按Alt+F2打开运行应用程序对话框。

  2. 在下拉文本框中输入“gksu /etc/init.d/xsupplicant start”,单击“运行”按钮,输入密码后,Xsupplicant就在后台启动运行了。

/etc/init.d/xsupplicant其实是Ubuntu控制xsupplicant守护进程(daemon)的脚本,若要查看该脚本的使用方法,请直接在终端中执行 /etc/init.d/xsupplicant脚本,将会得到详细的使用方法。



总结

    本文以实际的例子简单讲述了在Ubuntu中如何安装和设置跨平台的802.1x认证客户端软件Xsupplicant。使用Ubuntu,Xsupplicant可以在Ubuntu的官方源中找到,并且可以方便的下载和安装。在Ubuntu中,通过/etc/xsupplicant/xsupplicant.conf脚本来设置Xsupplicant,而配置文件/etc/default/xsupplicant则用于控制Xsupplicant是否启用。对于Xsupplicant的启用和关闭,可以通过执行/etc/init.d/xsupplicant脚本。

 
原创粉丝点击