53
M0N0 Wall 安安安安安 安安安安安安安安 安安安 [email protected] 111/06/0 9

M0N0 Wall 安裝及設定

Embed Size (px)

DESCRIPTION

M0N0 Wall 安裝及設定. 臺北市立松山工農 翁三偉 [email protected]. 2014/11/30. Facts. The m0n0wall system currently takes up less than 6 MB on the Compact Flash card (or CD-ROM), and contains all the required FreeBSD components (kernel, user programs) ipfilter PHP (CGI version) mini_httpd - PowerPoint PPT Presentation

Citation preview

Page 1: M0N0 Wall  安裝及設定

M0N0 Wall 安裝及設定臺北市立松山工農翁三偉[email protected]

112/04/24

Page 2: M0N0 Wall  安裝及設定

Facts The m0n0wall system currently takes up less than 6

MB on the Compact Flash card (or CD-ROM), and contains all the required FreeBSD components (kernel, user programs) ipfilter PHP (CGI version) mini_httpd MPD ISC DHCP server ez-ipupdate (for DynDNS updates) Dnsmasq (for the caching DNS forwarder) racoon (for IPsec IKE) UCD-SNMP choparp BPALogin

Page 3: M0N0 Wall  安裝及設定

On a net4501, m0n0wall provides a WAN <-> LAN TCP throughput of about 17 Mbps, including NAT, when run with the default configuration. On faster platforms (like net4801 or WRAP), throughput in excess of 50 Mbps is possible (and > 100 Mbps with newer standard PCs).

On a net4501, m0n0wall boots to a fully working state in less than 40 seconds after power-up, including POST (with a properly configured BIOS)

Page 4: M0N0 Wall  安裝及設定

web interface (supports SSL) serial console interface for recovery

set LAN IP address reset password restore factory defaults reboot system

wireless support (access point with PRISM-II/2.5/3 cards, BSS/IBSS with other cards including Cisco)

captive portal 802.1Q VLAN support stateful packet filtering

block/pass rules logging

NAT/PAT (including 1:1) DHCP client, PPPoE, PPTP and Tels

tra BigPond Cable support on the WAN interface

IPsec VPN tunnels (IKE; with support for hardware crypto cards and mobile clients)

PPTP VPN (with RADIUS server support)

static routes DHCP server caching DNS forwarder DynDNS client SNMP agent traffic shaper SVG-based traffic grapher firmware upgrade through the web br

owser Wake on LAN client configuration backup/restore host/network aliases

Page 5: M0N0 Wall  安裝及設定

安裝 m0n0wall 所需硬體設備PC 一部

主機工業主機一般 PC

儲存媒體硬碟光碟 + 軟碟 IDE 快閃模組 (DOM 、 DOC)

網路卡 2 片

Page 6: M0N0 Wall  安裝及設定

Soekris Engineering net4801

Page 7: M0N0 Wall  安裝及設定

盤儀科技 EmCORE-v611

Page 8: M0N0 Wall  安裝及設定

創見 IDE 快閃模組

Page 9: M0N0 Wall  安裝及設定

CF 轉 IDE( 函數科技 )

Page 10: M0N0 Wall  安裝及設定

Why m0n0?

考量因素1. BSD 系統

熟悉的作業系統環境,修改、更新容易。 又以 PHP 為 WEB 的語言,方便操作介面修改。

2. 使用 Web 作為設定、控制環境。3. 效能

可在較低等級的 CPU 上有不錯的表現、不需太大的 RAM 、 HDD

4. 可以從 CF 、 USB 開機

Page 11: M0N0 Wall  安裝及設定

本校使用 m0n0wall 情形無線閘道器 ( 前身為 GNATBOX ) 1 部

K6-450記憶體 128M網路卡 2 片軟體放置於 DOC

路由器 (EmCORE-v611) 2 部負責本校對外 10M 光纖路由軟體放置於 CF

Page 12: M0N0 Wall  安裝及設定

安裝 m0n0wall

選擇適合平台的軟體版本standard PC (CD-ROM version) net45xx/net48xx/WRAP embedded PC standard PC (CF/IDE version) or other emb

edded PC

Page 13: M0N0 Wall  安裝及設定

一般 PC 安裝下載 CF/IDE 影像檔 (generic-pc)下載 physdiskwrite

http://m0n0.ch/wall/downloads/physdiskwrite-0.5.zip

physdiskwrite [-u] generic-pc-xxx.img目的碟 > 800 MB 時,請加 – u請小心選擇正確的磁碟機

寫入影像至 CF 或 IDE 硬碟 ( 容量 > 5 MB)

Page 14: M0N0 Wall  安裝及設定

Physdiskwrite 執行時畫面

Page 15: M0N0 Wall  安裝及設定

使用光碟開機 ( 加軟碟 )

下載 ISO 影像檔 將 ISO 影像檔寫入至 CD-R ( 或 -RW)

Windows: 利用燒錄軟體 ( 如 :Nero) 來寫入 ISO 影像檔 (2048 bytes/sector, Mode-1)

取得一標準 1.44 MB 磁碟片,並格式化成 MS-DOS/FAT 。Windows: format A:

Page 16: M0N0 Wall  安裝及設定

開機後, console 畫面

Page 17: M0N0 Wall  安裝及設定

安裝後相關注意事項預設帳號 / 密碼為 admin/ mono詳細設定須以 web 來設定電腦須連接至 LAN Port ,以 DHCP 取得 IP 來進行設定。預設 IP 為 192.168.1.1( 可由 console 變更,預設 Gateway)密碼、 IP 及相關設定可利用 console 重設。

Page 18: M0N0 Wall  安裝及設定

一般設定 ( 一 )

Page 19: M0N0 Wall  安裝及設定

一般設定 ( 二 )

Page 20: M0N0 Wall  安裝及設定

進階設定 ( 一 )

Page 21: M0N0 Wall  安裝及設定

進階設定 ( 二 )

Page 22: M0N0 Wall  安裝及設定

Making a custom SSL certificate for the HTTPS webGUI

openssl req -new -nodes > cert.csropenssl x509 -in cert.csr -out cert.pem \ -req -signkey privkey.pem -days 365 The certificate can then be found in cert.

pem and the private key in privkey.pem

Page 23: M0N0 Wall  安裝及設定

複製 pem 時注意事項複製時,請複製整個檔案 ( 從 - 至 - )後貼上。

-----BEGIN CERTIFICATE-----………-----END CERTIFICATE-----

-----BEGIN RSA PRIVATE KEY-----……………….-----END RSA PRIVATE KEY-----

Page 24: M0N0 Wall  安裝及設定

進階設定 ( 三 )

Page 25: M0N0 Wall  安裝及設定

Interface 設定 Interfaces(assign)

Interface assignments VLANs

LAN IP Address 設定

WAN Static DHCP PPPoE PPTP BigPond 設定是否阻隔 private networks

Page 26: M0N0 Wall  安裝及設定

Firewall

Rules NAT

Inbound Server NAT 1:1 Outbound

Traffice shaper Rules Pipes Queues Magic shaper wizard

Aliases

Page 27: M0N0 Wall  安裝及設定

Services

DNS forwarderDynamic DNSDHCP serverDHCP relaySNMPProxy ARPCaptive portalWake on LAN

Page 28: M0N0 Wall  安裝及設定

Captive portal

Captive portal Pass-through MAC Allowed IP addresses

Page 29: M0N0 Wall  安裝及設定

Captive portal( 一 )

Page 30: M0N0 Wall  安裝及設定

Captive portal( 二 )

Page 31: M0N0 Wall  安裝及設定

Captive portal( 三 )

Page 32: M0N0 Wall  安裝及設定

Captive portal 注意事項套用變更設定時,會將所有的 client 斷線。請記得啟用 DHCP 。注意 default/maximum DHCP lease time 要比這裡的 timeout 時間長。請起動 DNS forwarder 的功能, client 才可被重導至認證畫面 ( 使用者不可以使用自定的 DNS) 。

Page 33: M0N0 Wall  安裝及設定

Pass-through MAC

以 MAC 為判斷標準。在表中者,可以不經認證直接使用網路。通常使用於用戶端。有 time-out 的限制。

Page 34: M0N0 Wall  安裝及設定
Page 35: M0N0 Wall  安裝及設定

Allowed IP addresses

以 IP 為判斷標準。在表中者,可以不經認證直接使用網路。通常使用於伺服器,以利使用者查看相關網頁。如 : 學校網頁,無線網路使用方法等。注意 : 此 IP 所有的 PORT 皆可存取不受限制。

Page 36: M0N0 Wall  安裝及設定
Page 37: M0N0 Wall  安裝及設定

VPN

IPsecPPTPOpenVPN

Page 38: M0N0 Wall  安裝及設定

Status

SystemInterfacesTraffic graphWirelessCaptive portal

Page 39: M0N0 Wall  安裝及設定

Diagnostics

System logsDHCP leasesIPsecPingReset stateBackup/RestoreFactory defaults Reboot system

Page 40: M0N0 Wall  安裝及設定

低階訊息及執行命令http://<m0n0wall-ip>/status.php . 可看一些低階訊息,也可觀看現在的 XML 構造。 http://<m0n0wall-ip>/exec.php ,可在 m0

n0wall 上直接執行命令。執行上要注意路徑的問題。

Page 41: M0N0 Wall  安裝及設定

客製 m0n0wall 影像檔入門 參考 Jean-Francois Theroux<[email protected]> 2004.08.11

注意 : 這份資料參考 FreeBSD 4.10 和 m0n0wall 1.1b 15 。 如果使用不同的版本,可能會有所不同。 首先你需要安裝 FreeBSD 4.10 。可從這裡得到 ftp://ftp.freebsd.org 。 這份資料不解釋怎樣安裝 FreeBSD ,相關的文件可在 (http://www.freebsd.org) 取得。 有了種工作環境,需要建立一個工作目錄。 建立 /devel 目錄以及一個 change/system 子目錄。 # cd $HOME # mkdir devel # mkdir devel/change # mkdir devel/system 進入你的新環境 ! # cd devel 下載 m0n0wall 影像檔修改成為我們所需要的環境。可用 wget 下載。 wget 可能未安裝,要安裝它可用 port 或 package 安裝。 # wget http://m0n0wall.cac.net/download/m0n0wall/generic-pc-1.1b15.img 可客製的大多數檔案在 mfsroot.gz 影像檔中。接下來的例子將顯示怎樣編輯那些檔案。

Page 42: M0N0 Wall  安裝及設定

將下載的檔案重新命名。 # mv generic-pc-1.1b15.img generic-pc-1.1b15.img.gz 解壓縮。 # gzip -d generic-pc-1.1b15.img.gz

在 Linux 上,使用 'mount -o loop imagefile /mount/point' mount 上影像檔。 在 FreeBSD 裡,建立一個虛擬裝置, 然後將檔案 mount 上虛擬的裝置。做法如下 : # vnconfig -s labels -c vn0 generic-pc-1.1b15.img # mount /dev/vn0a system/

複製 mfsroot.gz 至另一目錄,以方便我們修改。 # cp system/mfsroot.gz change/

將影像檔 umount 。 #umount system/

移除虛擬裝置。 #vnconfig -u vn0

Page 43: M0N0 Wall  安裝及設定

解壓縮 mfsroot.gz 。 # gzip -d change/mfsroot.gz

因為無法直接修改 mfsroot ,須先掛上檔案系統。 # vnconfig -s labels -c vn0 change/mfsroot # mount /dev/vn0 system/

可以編輯 m0n0wall 影像檔了。 大多數有趣的檔案在 ~/usr/local/www 下。 修改後,回到 $HOME/devel 。 # cd $HOME/devel

***警告 : 當在檔案系統時,如果這時 unmount 影像檔,會產生一些問題,可能必須重頭開始﹗ 現在 unmount 並重新封裝這影像檔。 # umount system/ # vnconfig -u vn0

Page 44: M0N0 Wall  安裝及設定

壓縮新 mfsroot 檔案系統,複製回影像檔。 # gzip -9 change/mfsroot # vnconfig -s labels -c vn0 generic-pc-1.1b15.img # mount /dev/vn0a system/ # cp change/mfsroot.gz system/ # umount system/ # vnconfig -u vn0

最後,重新壓縮影像檔。 # gzip -9 generic-pc-1.1b15.img # mv generic-pc-1.1b15.img.gz generic-pc-1.1b15.img

可以準備把你的影像檔上載到 m0n0wall 機器了。

Page 45: M0N0 Wall  安裝及設定

注意事項 ( 一 )

如果你想要對預設進行修改,編輯影像檔 mfsroot.gz 中 conf/config.xml 和 config.xml 。

如果你想要把更多 port 加進 NAT 中 ( 如 : SSH / HTTP / FTP) 來建立 rules ,請編輯 ~/usr/local/www/guiconfig.inc

-建議利用 diff 來建立 patches ,以利將來的版本更容易修正。 如︰ # diff -ur file.orig file > patch01

Page 46: M0N0 Wall  安裝及設定

注意事項 ( 一 )

登出視窗相關文字在 /usr/local/captiveportal/index.php 中

修改相關資料後,請移除無關的檔案,如 :*~ , *.bak 等。

Page 47: M0N0 Wall  安裝及設定

Firmware 更新

Page 48: M0N0 Wall  安裝及設定
Page 49: M0N0 Wall  安裝及設定

earlyshellcmd & shellcmd

在 config.xml 使用,無法在 webgui 中加入 earlyshellcmd 使用在 boot scripts 開始前執行特定的工作。 shellcmd 用在 boot scripts 完成後,執行特定的工作。 上列兩個指令置於 config.xml 檔案中 <system>….. <

/system>之間,如</system>

…………….. <shellcmd>/sbin/ipf -D</shellcmd> <shellcmd>/sbin/ipnat -CF</shellcmd>

……………….</system>

Page 50: M0N0 Wall  安裝及設定

備份 /回復設定檔 在 Diagnostics – Backup/Restore 中

Page 51: M0N0 Wall  安裝及設定

我看 m0n0 的缺點無中文操作介面

對熟悉的人,這不是問題 語系檔尚未獨立,修改相當麻煩

預設不會顯示線上有那些的使用者 修改一下即可

多片網卡的支援不是很好 LAN 、 WAN 受限 1 片,不太能夠有負載平衡的效果

說明文件不多 需靠maillist 及對 unix like 的了解

Page 52: M0N0 Wall  安裝及設定

我看 m0n0 的優點OpenSource更新快Free隨心所欲

Page 53: M0N0 Wall  安裝及設定

Q&A