G36_maid
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # NASA Hw06 OPNSense 41173058h 鍾詠傑 ## ref [OPNsence防火牆manual](https://docs.opnsense.org/manual/firewall.html) [opnsense-vs-pfsense](https://www.biteno.com/en/opnsense-vs-pfsense/) [lab6 mackmd](https://hackmd.io/@chyijia/SJB7aW73p#/12/4) [OPNsence alias](https://docs.opnsense.org/manual/aliases.html) [hping3](https://linux.die.net/man/8/hping3) [reporting_traffic](https://docs.opnsense.org/manual/reporting_traffic.html) [OPNSense Firewall Rules Explained (youtube)](https://youtu.be/kYFNa_zpeII?si=zjhUC4JXm4we3ou_) <div style="page-break-after:always;"></div> ## Short Answers (20%) ### 1. (5%) 在 OPNSense 防火牆 rule 的設定中,對封包的處置有 Block 跟 Reject 可以選擇。請說明兩者的差別,還有各自在什麼情況下較適合使用。 在OPNsense防火牆中,"Block"和"Reject"都是用於處理封包的選項,它們有一些重要的差異: 1. **Block(封鎖)**: - 當防火牆接收到一個符合Block規則的封包時,它會將該封包丟棄,並不會向發送者發送任何回應。 - Block通常用於阻止對來自不信任或有威脅的來源的封包的訪問,或者用於阻止某些通信端口的訪問,以確保不希望的流量無法進入網絡。 2. **Reject(拒絕)**: - 當防火牆接收到一個符合Reject規則的封包時,它會將該封包丟棄,並向發送者發送一個通知或拒絕訊息。這通常是一個ICMP錯誤訊息,告訴發送者封包被阻止。 - Reject通常用於明確地告知發送者其封包已被阻止,這有助於節省網路資源,因為發送者在收到響應後通常會停止重試。 適合使用的情況取決於您的安全需求和網路策略: - **Block的適用情況**: - 當您只需阻止特定封包進入網絡,而不希望通知發送者時,通常選擇Block。這可以讓攻擊者無法確定其攻擊是否成功,或是不存在該裝置或網域,增加了防禦的不可預測性。 - 如果您對發送者的身份不太在意,只是想阻止封包,則使用Block。 - **Reject的適用情況**: - 當您希望明確地告知發送者其封包已被阻止時,通常選擇Reject。這對於合法用戶來說是一個良好的回饋,可以幫助他們迅速意識到問題並採取適當的措施。 - 如果您希望發送者能夠清楚地知道其封包未被接受,並且希望他們停止重試或者嘗試與您的系統進行通信,則使用Reject。 <div style="page-break-after:always;"></div> ### 2. (5%) 在 OPNSense 防火牆 rule 的設定中,Source 跟 Destination 選擇“interface net”和“interface address”的差別是什麼? NET 會比對該子網路上的任何內容,且該位址僅符合指派給該子網路上 pfsense 的 IP 位址。 1. **Interface Net(介面網路)**: - 使用"interface net"選項時,您將規則應用到整個介面的IP地址範圍。這意味著規則將適用於介面上的所有IP地址,包括子網中的所有主機。 - 這對於需要規則應用於特定介面的所有主機或子網的情況非常有用。 2. **Interface Address(介面地址)**: - 使用"interface address"選項時,您可以具體指定來源或目的地的IP地址。您可以輸入單個IP地址、CIDR表示的子網,或者甚至是一個地址範圍。 - 這對於需要針對特定IP地址或特定IP地址範圍的情況非常有用,例如將規則應用於特定主機或一組主機。 <div style="page-break-after:always;"></div> ### 3. (5%) 請說明什麼是“stateful firewall”以及“stateless firewall”。OPNSense 是屬於哪一種? Ref: [OPNsence防火牆manual](https://docs.opnsense.org/manual/firewall.html) 1. **Stateful Firewall(有狀態防火牆)**: - 有狀態防火牆能夠追蹤封包的狀態和連接狀態。當一個封包通過防火牆時,防火牆會記錄下相關的連接資訊,例如源IP地址、目的IP地址、源端口、目的端口等。 - 一旦建立了初始的連接狀態,防火牆將根據先前建立的連接資訊來允許或阻止後續的封包。這樣可以實現對單個連接的跟蹤和管理,提高了安全性和效率。 - Stateful Firewall通常能夠檢測和防止一些攻擊,如基於連接的攻擊(如SYN洪水攻擊)和特定連接的不正常行為。 2. **Stateless Firewall(無狀態防火牆)**: - 無狀態防火牆僅僅根據單個封包的內容進行過濾和判斷,而不關心連接的狀態。每個封包被視為獨立的事件,沒有考慮先前的封包或連接。 - Stateless Firewall通常更加簡單和輕量,因為它們不需要維護連接狀態表,並且通常更快速地處理封包。 - 但是,無狀態防火牆無法提供與連接相關的安全功能,也無法對一些進階攻擊進行有效的防範。 OPNsense,屬於有狀態防火牆。OPNsense使用狀態資訊來追蹤和管理封包的連接狀態,並根據先前建立的連接資訊來進行過濾和授權。 <div style="page-break-after:always;"></div> ### 4. (5%) 目前系館防火牆是用 pfSense 架設。請簡單比較 pfSense 與 OPNSense 的差異,至少列舉兩樣? Ref: [opnsense-vs-pfsense](https://www.biteno.com/en/opnsense-vs-pfsense/) pfSense 和 OPNsense 都是基於 FreeBSD 的開源防火牆/路由器平台 OpnSense 專注於安全性和使用者友善性,而 pfSense 則提供靈活性和廣泛的插件。 這兩種解決方案都可以提供強大的防火牆保護並增強網路安全性。 - pfSense 的用戶界面較為傳統,使用基於古老技術的WebGUI,功能上可能較為陽春,但已經穩定存在多年。 - OPNsense 的用戶界面則更現代化和易於使用,具有更多的定製功能和視覺效果。它的WebGUI更加直觀和功能豐富,並且提供了更多的操作選項。 - pfSense 和 OPNsense 都擁有活躍的開發社區,但兩者的開發模式和社區參與有所不同。 - pfSense 的開發主要由商業公司 Netgate 領導,其核心代碼不是完全開源的,並且一些高級功能需要付費許可證。 - OPNsense 的開發由一個開源社區主導,它強調透明度和開放性,所有功能都是完全開源的,並且在功能和安全方面積極進行發展和改進。 <div style="page-break-after:always;"></div> ## OPNSense (80%) ### 5. (10%) 設定 10.5.0.0/24, 10.8.0.0/24, 10.99.0.0/24 給 VLAN 5, VLAN 8, VLAN 99 三個網路介面。 以下所有大題中,下列關係是等價的 OPT 1=VLAN 5 OPT 2=VLAN 8 OPT 3=VLAN 99 請參考 lab 6 ,三台Client VM 與 OPNSense 作法完全如法炮製 [lab6 hackmd](https://hackmd.io/@chyijia/SJB7aW73p#/12/4) 建立一台 FreeBsd64 並安裝 OPNSense 建立三台 alpine linux 並進行安裝 openssh vlan 各自建立 vlan 5, 8, 99 ![image](https://hackmd.io/_uploads/Syp9RCUy0.png) <div style="page-break-after:always;"></div> ### 6. (10%) 設定以下 alias: GOOGLE_DNS : 8.8.8.8, 8.8.4.4 ADMIN_PORTS : 22, 80, 443 CSIE_WORKSTATIONS : ws[1~5].csie.org 額外設定(後面會用到) : PrivateRanges: 10.[5,8,99].0.0/24 + __lan_network ![image](https://hackmd.io/_uploads/BkXLk1PyR.png) <div style="page-break-after:always;"></div> ### 7. (10%) 打開 OPNSense 的 SSH 功能。設定只有 VLAN 99 的機器可以透過 ADMIN_PORTS 連到 OPNSense。VLAN 5 與 VLAN 8 皆不允許。 進入 System: Settings: Administration:Secure Shell 勾選以下所有 - [x] Enable Secure Shell yes - [x] Permit root user login yes - [x] Permit password login - [x] SSH port 22 - [x] Listen Interfaces OPT3 (vlan99) ![image](https://hackmd.io/_uploads/Bkxsa7Ok0.png) 然後新增最上面的規則 允許Vlan99往防火牆 ADMIN_PORTS 的 TCP 連線 ![image](https://hackmd.io/_uploads/HkbgpQu1R.png) <div style="page-break-after:always;"></div> ### 8. (10%) VLAN 99 的機器只能存取以下位址或機器: • Google_DNS • CSIE_WORKSTATIONS(請提供 traceroute CSIE_WORKSTATIONS 的截圖,若你是 windows 本機可以加參數 -I ) • 這台 OPNSense(請提供 ssh 到 OPNSense management interface 的截圖) • Google_DNS 的解析規則(後四規則)請見下一題 ![image](https://hackmd.io/_uploads/SJpA2XO1A.png) ![Client99 [執行中] - Oracle VM VirtualBox 2024_4_1 下午 08_46_19](https://hackmd.io/_uploads/BkcT3Q_y0.png) <div style="page-break-after:always;"></div> ### 9. (10%) VLAN 5 的機器可以 ping 到 VLAN 8 的機器,反之則不行。 先在vlan 5 vlan 8 vlan 99 建立以下四個規則 ![image](https://hackmd.io/_uploads/ByIZZ1D1A.png) PrivateRanges: 10.[5,8,99].0.0/24 + __lan_network 目的寫在 Description 綜合效果是所有vlan無法互相ping 但是都能透過 DNS 解析到外網。 PrivateRanges = vlan5 + vlan8 + vlan99 + lan 拒絕所有本服務內部的需求。 如果是ping Firewall 的服務就用 ICMP 啟用, 否則如果是DNS 請求就使用本地 GOOGLE_DNS 進行解析 最後預設通過所有需求(最低優先) 首先三台機器的DNS server 都做以下設定(這裡用OPT1舉例) DNS servers = 8.8.8.8 , 8.8.4.4 ![image](https://hackmd.io/_uploads/SJkhwE_1A.png) 接下來分別設定 VLAN5 在 OPT1 的防⽕牆加上優先規則(打勾的),允許將來⾃ OPT1 (VLAN5) 傳到 OPT2 (VLAN8) 通過 ![image](https://hackmd.io/_uploads/BkrN_EuyR.png) 部分規則與知識參考這部影片 [OPNSense Firewall Rules Explained (youtube)](https://youtu.be/kYFNa_zpeII?si=zjhUC4JXm4we3ou_) <div style="page-break-after:always;"></div> ### 10. (10%) 在 2024/03/14 整天,VLAN5 這個 interface 不能通過任何的封包。 前往 Firewall: Settings: Schedules 建立當天的時間規則 March 14 - 15 0:00-0:00 ![Schedules _ Settings _ Firewall _ OPNsense.localdomain - Google Chrome 2024_3_31 下午 09_19_30](https://hackmd.io/_uploads/Skwl7kvyC.png) 然後特別 block Vlan5 (OPT1) 3/14 號無法通過任何封包 IPv4+6 ![image](https://hackmd.io/_uploads/SyeJH4OJA.png) <div style="page-break-after:always;"></div> ### 11. (10%) 請使用 hping3 或其他指令,每秒分別發送 0.1 Mb, 1 Mb, 10 Mb, 50 Mb 給 OPNsense server,觀察 reporting/traffic 中的 graph,試著分析圖形的變化。 可以看到隨著資料量擴大,該 Vlan 5 (OPT1) 所傳輸的流量也越大。 影片檔案 : https://drive.google.com/drive/folders/1GkiqopiF7e9u0OQT1L5tkvgh8B3EDinN?usp=sharing 指令: ``` hping3 -c 10 -d 100 -S 10.0.2.15 hping3 -c 10 -d 1000 -S <OPNsense_IP> hping3 -c 10 -d 10000 -S <OPNsense_IP> hping3 -c 10 -d 50000 -S <OPNsense_IP> ``` <div style="page-break-after:always;"></div> ### 12. (10%) 到 System > Configurations > Backups 中,下載 config.xml,將檔名依照你的學號改成如 b86506054.xml 的檔名,連同作業 PDF 一起繳交。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully