摘要
本文概要敘述令FreeRADIUS作為有線網路的authentication server的步驟,其中,選用的認證方法為TLS、並且使用容器來進行測試。
本文
IEEE 802.1X認證涉及了supplicant、authenticator、和authentication server等三個角色的相關細節請參考前文,各角色的設置也將依循前文、而僅做必要的調整。隨後將於Ubuntu 24.04虛擬機上使用Docker容器來建立各個角色,各角色的持久化資料將綁定至宿主的檔案系統,角色之間則透過自定義的Macvlan網路來彼此連接,其中,Docker映象檔使用了bionic版的Ubuntu。各角色容器化之後的關係示意圖如下。
![]() |
| 關係示意圖 |
步驟1,於宿主的shell下載freeradius-server倉庫,並且依據隨後啟動的FreeRADIUS容器進行調整。
git clone https://github.com/FreeRADIUS/freeradius-server.git -b release_3_0_16
cd freeradius-server
cd raddb/certs
nano ca.cnf
make ca.pem
make ca.der
nano server.cnf
make server.pem
nano client.cnf
make client.pem
make dh
步驟2,於宿主的shell下載hostap倉庫,並且依據隨後啟動的hostapd與wpa_supplicant容器進行調整。
git clone https://git.w1.fi/hostap.git -b hostap_2_6
cd hostap
nano hostapd/wired.conf
nano wpa_supplicant/examples/ieee8021x.conf
步驟3,於宿主的shell建立一個Macvlan網路,以作為FreeRADIUS與hostapd彼此連接之用。
sudo ip link add dummy0 type dummy
sudo ip link set dummy0 up
docker network create -d macvlan \
--subnet=192.168.250.0/24 \
--gateway=192.168.250.1 \
-o parent=dummy0 \
mv-radius
步驟4,於宿主的shell建立一個Macvlan網路,以作為hostapd與wpa_supplicant彼此連接之用。
sudo ip link add dummy1 type dummy
sudo ip link set dummy1 up
docker network create -d macvlan \
--subnet=192.165.100.0/24 \
--gateway=192.165.100.1 \
-o parent=dummy1 \
mv-eapol
步驟5,於宿主的shell撰寫一Dockerfile以建構FreeRADIUS所需的映象檔,接著使用該映象檔建立容器,進入容器的shell先複製相關檔案、再啟動FreeRADIUS。
cat <<EOF > freeradius.dockerfile
FROM ubuntu:bionic
RUN apt update
RUN apt install net-tools iputils-ping -y
RUN apt install freeradius -y
EOF
docker image build -f freeradius.dockerfile -t radius .
docker run --name ubuntu-inst-r -it --hostname radius --network mv-radius -v ~/Downloads:/experiment radius:latest bash
cp /experiment/log/freeradius-server/raddb/clients.conf /etc/freeradius/3.0/clients.conf
cp /experiment/log/freeradius-server/raddb/mods-config/files/authorize /etc/freeradius/3.0/users
cp /experiment/log/freeradius-server/raddb/mods-available/eap /etc/freeradius/3.0/mods-available/eap
cp /experiment/log/freeradius-server/raddb/certs/ca.pem /etc/freeradius/3.0/certs/
cp /experiment/log/freeradius-server/raddb/certs/server.key /etc/freeradius/3.0/certs/
cp /experiment/log/freeradius-server/raddb/certs/server.pem /etc/freeradius/3.0/certs/
cp /experiment/log/freeradius-server/raddb/certs/dh /etc/freeradius/3.0/certs/dh
chmod a+r /etc/freeradius/3.0/certs/server.pem
chmod a+r /etc/freeradius/3.0/certs/server.key
freeradius -X
步驟6,於宿主的shell撰寫一Dockerfile以建構hostapd所需的映象檔,接著使用該映象檔建立容器,進入容器的shell先複製相關檔案、再啟動hostapd。
cat <<EOF > hostapd.dockerfile
FROM ubuntu:bionic
RUN apt update
RUN apt install net-tools iputils-ping -y
RUN apt install hostapd -y
EOF
docker image build -f hostapd.dockerfile -t apd .
docker run --name ubuntu-inst-a -it --hostname apd --network mv-radius --network mv-eapol -v ~/Downloads:/experiment apd:latest bash
cp /experiment/log/hostap/hostapd/wired.conf ./wired.conf
hostapd -dd ./wired.conf
步驟7,於宿主的shell撰寫一Dockerfile以建構wpa_supplicant所需的映象檔,接著使用該映象檔建立容器,進入容器的shell先複製相關檔案、再啟動wpa_supplicant。
cat <<EOF > wpasupplicant.dockerfile
FROM ubuntu:bionic
RUN apt update
RUN apt install net-tools iputils-ping -y
RUN apt install wpasupplicant -y
EOF
docker image build -f wpasupplicant.dockerfile -t suppl .
docker run --name ubuntu-inst-s -it --hostname suppl --network mv-eapol -v ~/Downloads:/experiment suppl:latest bash
cp /experiment/log/freeradius-server/raddb/certs/ca.pem ./ca.pem
cp /experiment/log/freeradius-server/raddb/certs/client.pem ./client.pem
cp /experiment/log/freeradius-server/raddb/certs/client.key ./client.key
cp /experiment/log/hostap/wpa_supplicant/examples/ieee8021x.conf ./wired.conf
wpa_supplicant -ddd -Dwired -ieth0 -c./wired.conf
步驟8,既可以透過觀察各個容器的shell畫面來得知運行狀況,也可以在宿主的shell上以tshark捕捉訊框與封包來確認運行狀況。
![]() |
| FreeRADIUS執行畫面 |
![]() |
hostapd執行畫面 |
![]() |
| wpa_supplicant執行畫面 |
![]() |
| hostapd與wpa_supplicant之間的訊框交握 |
![]() |
| FreeRADIUS與hostapd之間的封包交握 |
完成。
網路狀態與檔案修改內容截圖如下。
![]() |
| 查詢Docker網路狀態 |
![]() |
| 修改authorize檔案(即users檔案) |
![]() |
| 修改eap檔案 |
![]() |
| 修改clients.conf檔案 |
![]() |
| 修改ca.conf檔案 |
![]() |
| 修改server.conf檔案 |
![]() |
| 修改client.conf檔案 |
![]() |
| 修改wired.conf檔案 |
![]() |
| 修改ieee8021x.conf檔案(即wired.conf) |
參考文獻
https://docs.docker.com/engine/install/ubuntu/
https://engineer-leo.blogspot.com/2020/02/freeradius-3-0-hostapd-2-6-wpasupplicant-2-4.html















沒有留言:
張貼留言