Chia Sẽ Kinh Nghiệm Về IT



Tìm Kiếm Với Google
-


Gởi Ðề Tài Mới  Gửi trả lời
 
Công Cụ Xếp Bài
Tuổi 07-05-2010, 11:36 AM   #1
thansau_239
Newbie
 
Avatar của thansau_239
 
Gia nhập: May 2010
Trả Lời: 15
Bảo mật Wireless với FreeRADIUS
Bài viết ghi lại việc dùng FreeRADIUS để xác thực Wireless. Mô hình như sau:




Bao gồm:

* 1 Linux server chạy Debian dùng để cài FreeRADIUS
* 1 Cisco Aironet 1240AG Access Point - ở đây đóng vai trò là NAS (Network Access Server)
* 1 Cisco Catalyst switch
* 2 clients: 1 dùng Slackware, 1 dùng Windows XP


Tiến hành cài FreeRADIUS:

Bước này không có gì khó khăn cả. Bạn download về, giải nén và cài như bình thường. Bạn có thể dùng –prefix=/usr/local/freeradius và sudo make install | tee /var/log/source/freeradius.log nếu muốn.


Tạo certificates:

Chuyển đến thư mục /usr/local/etc/raddb/certs, đọc README file và làm theo hướng dẫn. Mỗi khi tạo một client certificate đặt hết vào một thư mục với tên là common Name cho dễ tìm.
Code:

su -
cd /usr/local/etc/raddb/certs
mkdir quanta



Mình sửa Makefile như sau:
Code:

openssl req -new -out quanta/client.csr -keyout quanta/client.key -config ./client.cnf
openssl ca -batch -keyfile ca.key -cert ca.pem -in quanta/client.csr -key $(PASSWORD_CA) -out quanta/client.crt -extensions xpclient_ext -extfile xpextensions -config ./client.cnf
openssl pkcs12 -export -in quanta/client.crt -inkey quanta/client.key -out quanta/client.p12 -passin pass:$(PASSWORD_CLIENT) -passout pass:$(PASSWORD_CLIENT)
openssl pkcs12 -in quanta/client.p12 -out quanta/client.pem -passin pass:$(PASSWORD_CLIENT) -passout pass:$(PASSWORD_CLIENT)
cp quanta/client.pem quanta/$(USER_NAME).pem
cp quanta/client.key quanta/$(USER_NAME).key



(Trong bài viết mình dùng EAP-TLS nên yêu cầu cả server và client certs).

Lúc này trong thư mục quanta có những file sau:
Code:

# ls -l quanta
total 32
-rw-r--r-- 1 root radius 4104 2010-02-24 13:59 client.crt
-rw-r--r-- 1 root radius 1017 2010-02-24 13:59 client.csr
-rw-r--r-- 1 root radius 1743 2010-02-24 13:59 client.key
-rw-r--r-- 1 root radius 2493 2010-02-24 13:59 client.p12
-rw-r--r-- 1 root radius 3389 2010-02-24 13:59 client.pem
-rw-r--r-- 1 root radius 1743 2010-02-24 14:03 quan.ta$domain.vn.key
-rw-r--r-- 1 root radius 3389 2010-02-24 13:59 quan.ta$domain.vn.pem




Chỉnh sửa các file cấu hình:

/usr/local/etc/raddb/radiusd.conf:

* 1 Linux server chạy Debian dùng để cài FreeRADIUS
* 1 Cisco Aironet 1240AG Access Point - ở đây đóng vai trò là NAS (Network Access Server)
* 1 Cisco Catalyst switch
* 2 clients: 1 dùng Slackware, 1 dùng Windows XP


/usr/local/etc/raddb/eap.conf

* 1 Linux server chạy Debian dùng để cài FreeRADIUS
* 1 Cisco Aironet 1240AG Access Point - ở đây đóng vai trò là NAS (Network Access Server)
* 1 Cisco Catalyst switch
* 2 clients: 1 dùng Slackware, 1 dùng Windows XP


/usr/local/etc/raddb/clients.conf

* 1 Linux server chạy Debian dùng để cài FreeRADIUS
* 1 Cisco Aironet 1240AG Access Point - ở đây đóng vai trò là NAS (Network Access Server)
* 1 Cisco Catalyst switch
* 2 clients: 1 dùng Slackware, 1 dùng Windows XP


/usr/local/etc/raddb/users

* 1 Linux server chạy Debian dùng để cài FreeRADIUS
* 1 Cisco Aironet 1240AG Access Point - ở đây đóng vai trò là NAS (Network Access Server)
* 1 Cisco Catalyst switch
* 2 clients: 1 dùng Slackware, 1 dùng Windows XP


Thử start freeRADIUS ở debug mode: /usr/local/sbin/radiusd -X -x
Nếu bạn nhìn thấy những dòng cuối cùng như sau:

Wed Feb 24 17:35:28 2010 : Debug: listening on authentication address 172.16.128.12 port 1812
Wed Feb 24 17:35:28 2010 : Debug: listening on accounting address * port 1813
Wed Feb 24 17:35:28 2010 : Debug: listening on command file /usr/local/var/run/radiusd/radiusd.sock
Wed Feb 24 17:35:28 2010 : Info: Ready to process requests.



chứng tỏ bạn đã cấu hình và khởi động freeRADIUS thành công.


Cấu hình Access Point như sau:


aaa new-model
!
!
aaa group server radius rad_eap
server 172.16.128.12 auth-port 1812 acct-port 1813
...
dot11 ssid xx
authentication open eap eap_methods
authentication network-eap eap_methods
authentication key-management wpa
guest-mode
...
bridge irb
!
!
interface Dot11Radio0
no ip address
no ip route-cache
!
encryption mode ciphers tkip
...
ip default-gateway 172.16.128.252
ip http server
ip http authentication local
no ip http secure-server
ip http help-path http://www.cisco.com/warp/public/779...onfig/help/eag
ip radius source-interface BVI1
!
cdp timer 45
cdp holdtime 120
radius-server attribute 32 include-in-access-req format %h
radius-server host 172.16.128.12 auth-port 1812 acct-port 1813 key 7 131112011F0405242C
radius-server vsa send accounting



--> phần key này chính là Shared secret mà bạn đã gán trong file /usr/local/etc/raddb/clients.conf (41r0n3t).

Bây giờ chúng ta cấu hình Linux làm client để thử kết nối.
(coi như bổ sung vào phần còn thiếu trên wiki)

http://wiki.freeradius.org/WPA_HOWTO wrote:


... (at present, I have no experience with Linux clients and so cannot document this)



Nếu muốn dùng eapol_test bạn có thể:
Remove binary package của wpa_supplicant và compile lại từ source.
Code:

wget /path/to/wpa_supplicant-0.6.10.tar.gz
tar zxvf wpa_supplicant-0.6.10.tar.gz
cd wpa_supplicant-0.6.10/wpa_supplicant/
cp defconfig .config



Trong file .config, kiểm tra chắc chắn rằng

* 1 Linux server chạy Debian dùng để cài FreeRADIUS
* 1 Cisco Aironet 1240AG Access Point - ở đây đóng vai trò là NAS (Network Access Server)
* 1 Cisco Catalyst switch
* 2 clients: 1 dùng Slackware, 1 dùng Windows XP


Code:

make eapol_test
make
sudo make install



Soạn thảo file cấu hình /etc/wpa_supplicant.conf như sau:
Code:

network={
scan_ssid=1
ssid="xx"
key_mgmt=WPA-EAP
pairwise=CCMP TKIP
group=CCMP TKIP
eap=TLS
identity="quan.ta"
ca_cert="/etc/radiusclient/certs/ca.pem"
client_cert="/etc/radiusclient/certs/quan.ta@domain.vn.pem"
private_key="/etc/radiusclient/certs/quan.ta@domain.vn.key"
private_key_passwd="quan.ta_pass"
}



Trong đó:
+ ca.pem, quan.ta@domain.vn.pemquan.ta@domain.vn.key được copy từ server về
+ identity chính là common Name khi tạo client certificate
+ private_key_passwd chính là giá trị của output_password bạn đã gán trong client.cnf khi tạo client certificate (nếu bạn tạo client cert trực tiếp bằng openssl thì nó chính là passphrase).

Thử start wpa_supplicant ở debug mode:
Code:

wpa_supplicant -d -c /etc/wpa_supplicant.conf -i wlan0 -Dwext


Nếu bạn nhìn thấy những dòng như:

EAPOL: SUPP_BE entering state REQUEST
EAPOL: getSuppRsp
EAP: EAP entering state RECEIVED
EAP: Received EAP-Request id=8 method=13 vendor=0 vendorMethod=0
EAP: EAP entering state METHOD
SSL: Received packet(len=126) - Flags 0x80
SSL: TLS Message Length: 1130
SSL: (where=0x1001 ret=0x1)
SSL: SSL_connect:SSLv3 read server session ticket A
SSL: (where=0x1001 ret=0x1)
SSL: SSL_connect:SSLv3 read finished A
SSL: (where=0x20 ret=0x1)
SSL: (where=0x1002 ret=0x1)
SSL: 0 bytes pending from ssl_out
SSL: No Application Data included
SSL: No data to be sent out
EAP-TLS: Done
EAP-TLS: Derived key - hexdump(len=64): [REMOVED]
EAP-TLS: Derived EMSK - hexdump(len=64): [REMOVED]
SSL: Building ACK (type=13 id=8 ver=0)
EAP: method process -> ignore=FALSE methodState=DONE decision=UNCOND_SUCC
EAP: EAP entering state SEND_RESPONSE
EAP: EAP entering state IDLE
EAPOL: SUPP_BE entering state RESPONSE
EAPOL: txSuppRsp
TX EAPOL: dst=00:1b:2b:a9:0c:f0
EAPOL: SUPP_BE entering state RECEIVE
RX EAPOL from 00:1b:2b:a9:0c:f0
EAPOL: Received EAP-Packet frame
EAPOL: SUPP_BE entering state REQUEST
EAPOL: getSuppRsp
EAP: EAP entering state RECEIVED
EAP: Received EAP-Success
EAP: EAP entering state SUCCESS
CTRL-EVENT-EAP-SUCCESS EAP authentication completed successfully



đồng thời trên cửa sổ đang chạy radiusd bạn thấy:


Wed Feb 24 18:17:26 2010 : Auth: Login OK: [quan.ta] (from client aironet port 410 cli 001f.3bd8.62bf)
Wed Feb 24 18:17:26 2010 : Info: +- entering group post-auth {...}
Wed Feb 24 18:17:26 2010 : Info: ++[exec] returns noop
Sending Access-Accept of id 95 to 172.16.128.128 port 1645
MS-MPPE-Recv-Key = 0x3140c0a5ffd54cae58ec5d2bd7f68318ec0efc3edac4c903 6b3ba708188cf7a4
MS-MPPE-Send-Key = 0xf39ea7042321a9d7ee933520f6669758b43b38d5c1474854 89690842d26511a3
EAP-Message = 0x03080004
Message-Authenticator = 0x00000000000000000000000000000000
User-Name = "quan.ta"



chứng tỏ bạn đã được xác thực. Xin chúc mừng.

Cuối cùng là gán IP cho wlan0:
Code:

# dhcpcd wlan0
# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 00:1f:3b:d8:62:bf
inet addr:172.16.128.131 Bcast:172.16.128.255 Mask:255.255.255.0
inet6 addr: fe80::21f:3bff:fed8:62bf/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:57843 errors:0 dropped:0 overruns:0 frame:0
TX packets:27473 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18020958 (17.1 MiB) TX bytes:4709688 (4.4 MiB)




Phần cấu hình với Windows làm client các bạn có thể tham khảo trên wiki của freeRADIUS.

Nguồn Sưu Tầm
thansau_239 vắng mặt   Trả lời ngay kèm theo trích dẫn này
Gửi trả lời


Công Cụ
Xếp Bài

Quyền Hạn Của Bạn
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is Mở
Hình Cảm xúc đang Mở
[IMG] đang Mở
Mã HTML đang Tắt




Bây giờ là 08:14 PM. Giờ GMT +7



Diễn đàn tin học QuantriNet
quantrinet.com | quantrimang.co.cc
Founded by Trương Văn Phương | Developed by QuantriNet's members.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.