2010年11月11日 星期四

Captive Portal - CoovaChilli

OS:CentOS 5.5

Requirment:
gcc
openssl  openssl-devel
haserl
coovachilli
freeradius2  freeradius2-utils
iptables

1. 安裝二片網卡
vi  /etc/sysconfig/network-scripts/ifcfg-eth0  [外網卡]
DEVICE=eth0
BOOTPROTO=static
  ONBOOT=yes
  IPADDR=192.168.173.103
  NETMASK=255.255.255.0
  GATEWAY=192.168.173.1
vi  /etc/sysconfig/network-scripts/ifcfg-eth1  [內網卡]
DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.1.0.1
NETMASK=255.255.255.0
GATEWAY=192.168.173.103

2. 安裝相依套件
        yum  install  gcc  openssl  openssl-devel

3. 下載Haserl套件包
        wget  http://sourceforge.net/projects/haserl/files/haserl-devel/0.9.26/haserl-0.9.26.tar.gz/download

4. 解壓縮,編譯安裝
        tar  -zxvf  haserl-0.9.26.tar.gz
        cd  haserl-0.9.26
        ./configure
        make; make  install


5. 下載Coova-Chilli套件包
        cd  ~
        wget  http://ap.coova.org/chilli/coova-chilli-1.2.5.tar.gz

6. 解壓縮,編譯安裝
        tar  -zxvf  coova-chilli-1.2.5.tar.gz
        cd coova-chilli-1.2.5
        ./configure  --enable-miniportal  --with-openssl
        make; make install

7. 建置Coova-Chilli程式執行PID存放目錄
        mkdir  -p  /usr/local/var/run

8. 修改chilli script執行檔
        vi  /usr/local/etc/init.d/chilli
start)
...
$(which  start-stop-daemon  2>/dev/null)
stop)
...
$(which  start-stop-daemon  2>/dev/null)

9. 設定開機啟動chilli
        ln  -s  /usr/local/etc/init.d/chilli  /etc/init.d/chilli
        chkconfig  chilli  on


10. 設定chilli組態檔
        cd  /usr/local/etc/chilli
        cp  defaults  config
        vi  config
        HS_WANIF=eth0   [對外網卡]
        HS_LANIF=eth1   [對內網卡]
        HS_NETWORK=10.1.0.0   [內網網段]
        HS_NETMASK=255.255.255.0   [內網netmask]
        HS_UAMLISTEN=10.1.0.1   [內網卡IP]
        HS_DNS1=168.95.1.1   [指派內往使用DNS]
        HS_RADIUS=localhost   [radius server]
        HS_RADSECRET=testing123   [radius溝通密碼]

11. 設定Chilli主機路由
        yum  install  iptables

12. 設定chilli server的NAT機制,並且開機啟動
vi  /etc/sysctl.conf
net.ipv4.ip_forward  =  1
echo  "1"  >  /proc/sys/net/ipv4/ip_forward
iptables  -t  nat  -A  PREROUTING  -s  10.1.0.0/24  -d  192.168.173.103  -j  ACCEPT
iptables  -t  nat  -A  PREROUTING  -s  192.168.173.103  -d  10.1.0.0/24  -j  ACCEPT
iptables  -t  nat  -A  POSTROUTING  -s  10.1.0.0/24  -d  192.168.173.103  -j  ACCEPT
iptables  -t  nat  -A  POSTROUTING  -s  192.168.173.103  -d  10.1.0.0/24  -j  ACCEPT
iptables  -t  nat  -A  POSTROUTING  -s  10.1.0.0/24  -o  eth0  -j  SNAT  --to-source  192.168.173.103
iptables-save  >  nat_rule
cp  nat_rule  /etc/sysconfig/iptables
      
13. 安裝radius機制驗證
        yum  install  freeradius2  freeradius2-utils

14. 建立使用者,驗證radius機制
        vi  /etc/raddb
        test  Cleartext-Password  :=  "testing"
        radiusd  -X
        radtest  test  testing  127.0.0.1  0  testing123

15. 使用內網主機測試
開啟瀏覽器上網,會自動導到Chiili Captive Portal驗證頁面,輸入radius上建立的帳密即可































參考文章:
http://coova.org/CoovaChilli
http://www.communig8.com/articles/78-coovachilli-test-vm-configuration-part-i-31-august-2010.html
http://www.communig8.com/articles/79-coovachilli-test-vm-configuration-part-ii-1-september-2010.html
http://www.freeradius.org

沒有留言:

張貼留言