[圖文]Ubuntu的802.1x解決方案:Xsupplicant

** 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腳本。

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章