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 New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # NASA HW 7 * 41173058h * 鍾詠傑 ## ref [root name servers](https://www.iana.org/domains/root/servers) [pDNS doc](https://doc.powerdns.com/authoritative/backends/) [pDNS github](https://github.com/PowerDNS) [pDNS wiki](https://github.com/powerdns/pdns/wiki) [pDNSdocs](https://doc.powerdns.com/authoritative/guides/basic-database.html) [socker sol](https://www.reddit.com/r/sysadmin/comments/jac1mu/powerdns_error_unable_to_bind_udp_socket_to/) [systemd](https://learn.microsoft.com/zh-tw/windows/wsl/systemd) [backend](https://doc.powerdns.com/authoritative/backends/generic-sqlite3.html) [PowerDNS-Admin](https://github.com/PowerDNS-Admin/PowerDNS-Admin) [General installation](https://github.com/PowerDNS-Admin/PowerDNS-Admin/blob/master/docs/wiki/install/General.md) [Installing PowerDNS-Admin on Ubuntu or Debian based systems](https://github.com/PowerDNS-Admin/PowerDNS-Admin/blob/master/docs/wiki/install/Running-PowerDNS-Admin-on-Ubuntu-or-Debian.md) <div style="page-break-after:always;"></div> ## 1 ### 1 DNS 1. DNS 是 Domain Name System 的縮寫,它是一種用於將人類可讀的域名轉換為電腦可理解的 IP 地址的分散式命名系統。當您在瀏覽器中輸入網址時,例如"www.example.com",瀏覽器需要知道該網址對應的伺服器的 IP 地址,以便建立連接。DNS 就像是互聯網的電話簿,它將域名映射到相應的 IP 地址,從而使網際網路上的設備能夠相互通信。 <div style="page-break-after:always;"></div> ### 2 DDNS 2. DDNS 是 Dynamic Domain Name System 的縮寫,它是一種動態域名系統。與傳統的靜態 DNS 不同,DDNS 允許動態分配 IP 地址的設備(例如家庭路由器)在其 IP 地址更改時更新其對應的域名記錄。這對於家庭用戶或小型企業而言特別有用,因為它們通常使用的是動態 IP 地址,而不是靜態 IP 地址。透過使用 DDNS,這些設備可以始終使用相同的域名訪問,而不必擔心其 IP 地址變化導致連接問題。 <div style="page-break-after:always;"></div> ### 3 root name servers 全球共有13台 root name servers [root name servers](https://www.iana.org/domains/root/servers) <div style="page-break-after:always;"></div> ### 4 TXT records 除了作為註解之外,TXT 記錄還有許多實際應用,其中之一是用於電子郵件驗證。例如,SPF(Sender Policy Framework)和 DKIM(DomainKeys Identified Mail)是兩種常見的電子郵件驗證機制,它們都使用 TXT 記錄來實現。 以 SPF 為例,域名的管理者可以在其 DNS 設置中添加一個 TXT 記錄,該記錄包含一組允許發送電子郵件的郵件伺服器的 IP 地址。當接收者的郵件伺服器收到一封郵件時,它可以查詢發件人域名的 SPF 記錄,以驗證郵件是否來自已授權的郵件伺服器。這有助於減少垃圾郵件和偽造郵件的風險,提高電子郵件傳遞的可靠性和安全性。 <div style="page-break-after:always;"></div> ## 2 ### 結果 `根據您提供的查詢結果,從根名稱伺服器到 www.csie.ntu.edu.tw 的查詢路徑如下: 1. 根名稱伺服器: - IP: a.root-servers.net. - IP: b.root-servers.net. - IP: c.root-servers.net. - IP: d.root-servers.net. - IP: e.root-servers.net. - IP: f.root-servers.net. - IP: g.root-servers.net. - IP: h.root-servers.net. - IP: i.root-servers.net. - IP: j.root-servers.net. - IP: k.root-servers.net. - IP: l.root-servers.net. - IP: m.root-servers.net. 2. .tw 名稱伺服器: - tw. NS a.dns.tw. - tw. NS b.dns.tw. - tw. NS c.dns.tw. - tw. NS d.dns.tw. - tw. NS e.dns.tw. - tw. NS f.dns.tw. - tw. NS g.dns.tw. - tw. NS h.dns.tw. - tw. NS anytld.apnic.net. 3. ntu.edu.tw 名稱伺服器: - ntu.edu.tw. NS dns.ntu.edu.tw. - ntu.edu.tw. NS ntu3.ntu.edu.tw. - ntu.edu.tw. NS dns.tp1rc.edu.tw. 4. csie.ntu.edu.tw 名稱伺服器: - csie.ntu.edu.tw. NS csman2.csie.ntu.edu.tw. - csie.ntu.edu.tw. NS ntuns.ntu.edu.tw. - csie.ntu.edu.tw. NS csman.csie.ntu.edu.tw. 5. www.csie.ntu.edu.tw 的 IP 地址: - www.csie.ntu.edu.tw. A 140.112.30.26 <div style="page-break-after:always;"></div> ### result ``` miku@DESKTOP-HLSSCVT:~$ dig +trace www.csie.ntu.edu.tw ; <<>> DiG 9.18.18-0ubuntu0.22.04.2-Ubuntu <<>> +trace www.csie.ntu.edu.tw ;; global options: +cmd . 87203 IN NS a.root-servers.net. . 87203 IN NS b.root-servers.net. . 87203 IN NS c.root-servers.net. . 87203 IN NS d.root-servers.net. . 87203 IN NS e.root-servers.net. . 87203 IN NS f.root-servers.net. . 87203 IN NS g.root-servers.net. . 87203 IN NS h.root-servers.net. . 87203 IN NS i.root-servers.net. . 87203 IN NS j.root-servers.net. . 87203 IN NS k.root-servers.net. . 87203 IN NS l.root-servers.net. . 87203 IN NS m.root-servers.net. . 87203 IN RRSIG NS 8 0 518400 20240420050000 20240407040000 5613 . ZhXQ/7ijGbesnEykk6GlTV0uB5AVdgh1yenLcuLCSaBTGw8YgfWWb7i3 hoQiRZICY+++iUQIE2/ELR/ykCYjGD5HwxS0lqfbUZvaY0IcKQ5lsAk3 OQlSEtmpQ+3158l9j5mjiTtb13L7QeJOr+cmJn4Auj+7IWei2irkQdu9 72VOAitFOv/MOin/1LTxAqQvQsK4TRUoQOBSAyJSQIfEqRZI3XhsXbTO itYMIl/MNFYmxGcmEZEAVlzLAHf9EM6yEKCdjQtjdiolzrGXoroBIGEp msbdt1yzs+DcfdJLKGfZujPhvVvwVBEvhfnBZlDLdljcG0pVUcMuMxsz ubJELw== ;; Received 525 bytes from 172.31.224.1#53(172.31.224.1) in 860 ms tw. 172800 IN NS a.dns.tw. tw. 172800 IN NS b.dns.tw. tw. 172800 IN NS c.dns.tw. tw. 172800 IN NS d.dns.tw. tw. 172800 IN NS e.dns.tw. tw. 172800 IN NS f.dns.tw. tw. 172800 IN NS g.dns.tw. tw. 172800 IN NS h.dns.tw. tw. 172800 IN NS anytld.apnic.net. tw. 86400 IN DS 51277 8 2 462DA9AF501D2B1EEF6725522DB5972F8CD2490B51D92088FF1E3D2D E0EC7BCD tw. 86400 IN RRSIG DS 8 1 86400 20240420050000 20240407040000 5613 . bB0xNjHOe6pkV/9LpEW/DzuMHtwozTlszTNaFPkO7LRu1WbbEt/+ox7D y+xgud3mLTsva5R7p44ckvH9m14DigO7G2y4TqmwrpfL1AU5rwjkNmbz hCqQcxd3GpXyaCny9TLY0UGeTluKm1/5yt579/QgtKNQ3cwKxdLb43+6 4fP/6YknTbOOqpjToP8RqwSQVSIe1HAChTd3Hb2SSaWopcR+ysH/Jpg6 heJ9fiz8oFUjR52nW0V+Zh/a7zF8PKkkpYRbxha1Qncb3dOu5YqAYmWn s91cFW26MZSvyB1Levy7w1RQjeHC3yKQ4UT7cBqWRMyrKs2knQma0In1 TOtPXw== ;; Received 885 bytes from 170.247.170.2#53(b.root-servers.net) in 230 ms ntu.edu.tw. 300 IN NS dns.ntu.edu.tw. ntu.edu.tw. 300 IN NS ntu3.ntu.edu.tw. ntu.edu.tw. 300 IN NS dns.tp1rc.edu.tw. CFHNKGNQ5QOBIB61FV5AKT0CR5554JKT.edu.tw. 300 IN NSEC3 1 0 10 5B7A95B3E7E6DD0C CFN2AMOOKK0JTMIHE976IRUQPHJJED5N NS CFHNKGNQ5QOBIB61FV5AKT0CR5554JKT.edu.tw. 300 IN RRSIG NSEC3 8 3 300 20240410171756 20240406161756 33219 edu.tw. TcC+thTOZPE+dV/7ttpVsuoSm26If2WrHrDiOVGAx8zhzQtG0TcrZjvi /XQtplFhkF4BAAxXNIZFoYofNuBCi6O76qUqUo69z0t9maHhCk71AjUa TPoISDUfXnTIXLXhsaqvSdYU5x1g5J0IrTKvYOLFYjO5jqqpOy2uk7uI pGY= ;; Received 433 bytes from 182.173.0.10#53(f.dns.tw) in 0 ms ;; UDP setup with 2001:288:1001:254::4#53(2001:288:1001:254::4) for www.csie.ntu.edu.tw failed: network unreachable. ;; UDP setup with 2001:288:1001:254::4#53(2001:288:1001:254::4) for www.csie.ntu.edu.tw failed: network unreachable. ;; UDP setup with 2001:288:1001:254::4#53(2001:288:1001:254::4) for www.csie.ntu.edu.tw failed: network unreachable. csie.ntu.edu.tw. 14400 IN NS csman2.csie.ntu.edu.tw. csie.ntu.edu.tw. 14400 IN NS csman.csie.ntu.edu.tw. ;; Received 121 bytes from 163.28.16.10#53(dns.tp1rc.edu.tw) in 0 ms www.csie.ntu.edu.tw. 600 IN A 140.112.30.26 www.csie.ntu.edu.tw. 600 IN RRSIG A 7 5 600 20240426061133 20240327061133 39023 csie.ntu.edu.tw. I1oK7sS1MyUuQR5ofE6D1fkaFzCnpVV74XD9VkrDyfojMSIajCtoyRUH n9kmRe+hcRpmkDgAcEHtZAAeXzSkPbDgeTaoFKRbWLH2+1i2Ly2Is9vp d06qvt1HE8j1C9ibon9eiGAVIs7uhpImaF2fL30nJKdb01QW4dGhvMic ALAZUJOGPKxZSmCYYe99eCPNIiuSrDs+He7lAdJKgKq9FFAk+Ed3Hsew 8Jo2PRk2eMBalyn8umjD+NXi4tKODWgAjGR2kYbgM5huHTLfmKNUW4yK w/b6wKq8To4VlucLtt6+cvRv9fXHsMxQQu+/9XETAIkv0uwojLEL3E1E 4PCQwQ== csie.ntu.edu.tw. 600 IN NS csman2.csie.ntu.edu.tw. csie.ntu.edu.tw. 600 IN NS ntuns.ntu.edu.tw. csie.ntu.edu.tw. 600 IN NS csman.csie.ntu.edu.tw. csie.ntu.edu.tw. 600 IN RRSIG NS 7 4 600 20240426061133 20240327061133 39023 csie.ntu.edu.tw. PBQqIiK0YOTtYKKjTRmiVgTi4a2gjcByg/hHpob8S2xrzwsBvc8bnndu ofN3YqQ2xjre7SbLCpvb83tPIkypf4lPYILdSEa8Js67jbzFaEl6Zkqf YMqJ9MhcTh2VjckVyMCLBJUha7qBkuxEdUqjyENTyDYezQm9hVvCGjNj tyLDIU6Qp59Ozq55BgnctoCz0sYB8ZqKq9Yva2vEm0lPL659VkAbLz7q F61+qZ3a5xjVpG+xNh8p8w5GaaJY5F69zAzidK4d1fVUOrGf4VB/QEFY cpSSigWPDbhNWOfD/3uzCTspBRU/f3Cwj1X6W76+0oBodButbWbtX+6r uJUENQ== ;; Received 1066 bytes from 140.112.30.13#53(csman.csie.ntu.edu.tw) in 0 ms ``` <div style="page-break-after:always;"></div> ### 截圖 ![image](https://hackmd.io/_uploads/SyhSvxelR.png) <div style="page-break-after:always;"></div> ## 3 設計 NTU CSIE 的 `*.csie.ntu.edu.tw` 網域的 DNS 架構需要考慮高可用性、安全性和可擴展性等因素。以下是一些設計方向: ### 1 設計方向 1. **多台伺服器的分散式架構**: - 使用多台伺服器來分散 DNS 查詢負載,並實現冗餘和備援。 - 這些伺服器可以部署在不同的地理位置,以提高系統的可用性和容錯能力。 - 配置主要和次要 DNS 伺服器,以便在其中一台伺服器失效時自動切換到另一台。 2. **自動化備份和恢復機制**: - 定期備份 DNS 記錄和設定,並將其存儲在安全的地方。 - 實施自動化恢復機制,以在伺服器上的 DNS 記錄丟失或損壞時能夠快速恢復。 3. **實驗室子域名的管理**: - 提供一個管理界面或工具,使實驗室能夠請求並管理自己的子域名。 - 實現自動化程序來處理這些請求,以確保有效且及時的管理。 4. **防禦 DNS 攻擊**: - 實施流量監控和流量限制措施,以應對 DNS flooding 攻擊。 - 配置防火牆和入侵檢測系統來檢測和阻止 DNS amplification 攻擊。 - 使用安全的軟體和硬體來防止 DNS 竄改攻擊,如 DNSSEC 和適當的加密。 5. **監控和日誌**: - 實施監控系統來監視 DNS 伺服器的運行狀態和性能。 - 定期審查 DNS 日誌以檢測任何異常活動或潛在的攻擊。 <div style="page-break-after:always;"></div> ### 2 危機應對 1. **如果今天其中一台伺服器壞掉了怎麼辦?** - 上述方案中使用了多台伺服器的分散式架構。這意味著即使其中一台伺服器壞掉,其他伺服器仍然可以處理 DNS 查詢,從而保持服務的可用性。 2. **如果今天系館停電導致所有機房下線怎麼辦?** - 配置主要和次要 DNS 伺服器,這些伺服器可以位於不同的地理位置,例如不同的系館。這樣即使某個機房停電,其他機房的 DNS 伺服器仍然可以繼續提供服務。 3. **如果因為某些原因導致伺服器上的 DNS records 不見了怎麼辦?** - 實施自動化備份和恢復機制,定期備份 DNS 記錄和設定。即使某些記錄不見了,也可以快速恢復到先前的狀態。 4. **有些實驗室想要擁有自己的 subdomain,該如何實現?** - 提供一個管理界面或工具,使實驗室能夠請求並管理自己的子域名。並實現自動化程序來處理這些請求,以確保有效且及時的管理。 5. **如何應對 DNS flooding attack?** - 實施流量監控和流量限制措施,這些措施可以檢測和阻止異常的 DNS 查詢流量,防止 DNS 伺服器被淹沒。 6. **如何應對 DNS amplification attack?** - 配置防火牆和入侵檢測系統來檢測和阻止 DNS amplification 攻擊。並且定期更新軟體和硬體,以確保它們能夠有效地防止這類攻擊。 7. 如何確保對 *.csie.ntu.edu.tw 的 query response 不會被攻擊者竄改成 malicious ip 呢?** - 使用安全的軟體和硬體來防止 DNS 竄改攻擊,如 DNSSEC 和適當的加密。這些措施可以確保 DNS 回應的完整性,並防止攻擊者竄改 DNS 記錄。 <div style="page-break-after:always;"></div> ## 4. [pDNS doc](https://doc.powerdns.com/authoritative/backends/) [pDNS github](https://github.com/PowerDNS) [pDNS wiki](https://github.com/powerdns/pdns/wiki) [pDNSdocs](https://doc.powerdns.com/authoritative/guides/basic-database.html) 設定 SQLite3 後端 ```bash sudo apt-get update sudo apt-get install pdns-server pdns-backend-sqlite3 ``` 編輯`pdns.conf`文件新增以下內容 ```bash sudo vim /etc/powerdns/pdns.conf launch=gsqlite3 gsqlite3-database=/var/lib/powerdns/pdns.sqlite3 ``` 建立資料庫: ```bash sudo mkdir /var/lib/powerdns sudo sqlite3 /var/lib/powerdns/pdns.sqlite3 < /usr/share/doc/pdns-backend-sqlite3/schema.sqlite3.sql sudo chown -R pdns:pdns /var/lib/powerdns ``` ```bash sudo systemctl start pdns or sudo systemctl restart pdns ``` 檢查 ```bash systemctl status pdns ``` ![image](https://hackmd.io/_uploads/HkOmzQggA.png) <div style="page-break-after:always;"></div> ### 測試 ```bash $ sudo -u pdns pdnsutil create-zone example.com ns1.example.com Creating empty zone 'example.com' Also adding one NS record $ sudo -u pdns pdnsutil add-record example.com '' MX '25 mail.example.com' New rrset: example.com. 3005 IN MX 25 mail.example.com $ sudo -u pdns pdnsutil add-record example.com. www A 192.0.2.1 New rrset: www.example.com. 3005 IN A 192.0.2.1 ``` 如果我們現在重新查詢資料庫, www.example.com ```bash $ dig +short www.example.com @127.0.0.1 192.0.2.1 $ dig +short example.com MX @127.0.0.1 25 mail.example.com ``` ![image](https://hackmd.io/_uploads/SJVUGQglA.png) 如果失敗請看安裝問題 <div style="page-break-after:always;"></div> ### 安裝問題 #### 問題1: binding to UDP socket: Address already in use #### 解決1: [socket solution](https://www.reddit.com/r/sysadmin/comments/jac1mu/powerdns_error_unable_to_bind_udp_socket_to/) or ```bash sudo vim /etc/powerdns/pdns.conf local-port=5300 ``` <div style="page-break-after:always;"></div> #### 問題2: system has not been booted with systemd as init system pid 1 . can't operate. #### 解決2: 強制執行(前台) ```bash cd /usr/sbin ./pdns_server --daemon=no --guardian=no --loglevel=9 ``` or [systemd](https://learn.microsoft.com/zh-tw/windows/wsl/systemd) <div style="page-break-after:always;"></div> #### 後端設定: [backend](https://doc.powerdns.com/authoritative/backends/generic-sqlite3.html) <div style="page-break-after:always;"></div> ## powerDNS admin [PowerDNS-Admin](https://github.com/PowerDNS-Admin/PowerDNS-Admin) 我這邊選擇直接在local安裝,不使用Docker 按照wiki操作: [General installation](https://github.com/PowerDNS-Admin/PowerDNS-Admin/blob/master/docs/wiki/install/General.md) [Installing PowerDNS-Admin on Ubuntu or Debian based systems](https://github.com/PowerDNS-Admin/PowerDNS-Admin/blob/master/docs/wiki/install/Running-PowerDNS-Admin-on-Ubuntu-or-Debian.md) 首先設定資料庫(sqlite3跳過) [Database Setup](../database-setup/README.md) <div style="page-break-after:always;"></div> ### 建立PowerDNS API 設定 [PowerDNS API doc](https://doc.powerdns.com/md/httpapi/README/#api-specification) 編輯`pdns.conf`文件新增以下內容 ```bash api=yes api-key=changeme # Needed before 4.1.0 webserver=yes ``` 重新啟動 pdns_server 後,測試以下內容 ```bash # List zones curl -H 'X-API-Key: changeme' http://127.0.0.1:8081/api/v1/servers/localhost/zones | jq . # Create new zone "example.org" with nameservers ns1.example.org, ns2.example.org curl -X POST --data '{"name":"example.org.", "kind": "Native", "masters": [], "nameservers": ["ns1.example.org.", "ns2.example.org."]}' -v -H 'X-API-Key: changeme' http://127.0.0.1:8081/api/v1/servers/localhost/zones | jq . # Show the new zone curl -H 'X-API-Key: changeme' http://127.0.0.1:8081/api/v1/servers/localhost/zones/example.org. | jq . # Add a new record to the new zone (would replace any existing test.example.org/A records) curl -X PATCH --data '{"rrsets": [ {"name": "test.example.org.", "type": "A", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "192.0.5.4", "disabled": false } ] } ] }' -H 'X-API-Key: changeme' http://127.0.0.1:8081/api/v1/servers/localhost/zones/example.org. | jq . # Combined replacement of multiple RRsets curl -X PATCH --data '{"rrsets": [ {"name": "test1.example.org.", "type": "A", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "192.0.2.5", "disabled": false} ] }, {"name": "test2.example.org.", "type": "AAAA", "ttl": 86400, "changetype": "REPLACE", "records": [ {"content": "2001:db8::6", "disabled": false} ] } ] }' -H 'X-API-Key: changeme' http://127.0.0.1:8081/api/v1/servers/localhost/zones/example.org. | jq . ``` #### 截圖 應該要印出一些json內容 有印出就是api正常運作 ![image](https://hackmd.io/_uploads/S1Q17Xxl0.png) <div style="page-break-after:always;"></div> ### 安裝 PowerDNS Admin 所需套件 ```bash sudo apt install -y python3-dev git libsasl2-dev libldap2-dev python3-venv libmariadb-dev pkg-config build-essential curl libpq-dev ``` ### 安裝 NodeJs ```bash curl -sL https://deb.nodesource.com/setup_14.x | sudo bash - sudo apt install -y nodejs ``` ### 安裝 yarn 來配置資源文件 ```bash curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt update && sudo apt install -y yarn ``` For older Debian systems: ```bash sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt update -y sudo apt install -y yarn ``` <div style="page-break-after:always;"></div> ### 建立 virtualenv 虛擬環境 _**Note:**_ Please adjust `/opt/web/powerdns-admin` to your local web application directory ```bash git clone https://github.com/PowerDNS-Admin/PowerDNS-Admin.git /opt/web/powerdns-admin cd /opt/web/powerdns-admin python3 -mvenv ./venv ``` 啟動您的 python3 環境並安裝 requirements.txt ```bash source ./venv/bin/activate pip install --upgrade pip pip install -r requirements.txt ``` <div style="page-break-after:always;"></div> ## 運行 PowerDNS-Admin 建立 PowerDNS-Admin 設定檔並根據您的用例進行必要的變更。確保將 SECRET_KEY 變更為您自己產生的長隨機字串(請參閱 Flask 文件) [Flask](https://flask.palletsprojects.com/en/1.1.x/config/#SECRET_KEY) ```bash cp /opt/web/powerdns-admin/configs/development.py /opt/web/powerdns-admin/configs/production.py vim /opt/web/powerdns-admin/configs/production.py export FLASK_CONF=../configs/production.py ``` 進行資料庫遷移 ```bash export FLASK_APP=powerdnsadmin/__init__.py flask db upgrade ``` 產生必須文件 ```bash yarn install --pure-lockfile flask assets build ``` 現在您可以透過命令運行PowerDNS-Admin 我這裡使用tmux掛在前台運行 同時可以查看所有發生的變化 ```bash ./run.py ``` 進入`127.0.0.1:9191`可以特別設定,但這是預設port ![image](https://hackmd.io/_uploads/ryqXmdJg0.png) 建立帳號後登入即可 ![image](https://hackmd.io/_uploads/HyfcGdyg0.png) 連接API (pnds.conf裡面的) ![image](https://hackmd.io/_uploads/BJ5wUmex0.png) <div style="page-break-after:always;"></div> ### 3. 透過 PowerDNS-Admin 新增 records。請根據以下故事新增 DNS records,並附上 dig 後的截圖 ### 功能1 建立zone nasa.csie.tw add Record | Name | Type | Status | TTL | Data | | ---- | ---- | ------ | ---- | --- | | verification | TXT | Active | 60 | "I LOVE NASA" | ![image](https://hackmd.io/_uploads/Sya8pygeR.png) <div style="page-break-after:always;"></div> ### 功能2 建立 Zone Records - sub.nasa.csie.tw | Name | Type | Status | TTL | Data | | ---- | ---- | ------ | ---- | --- | |* | NS | Active | 60 | subns.nasa.csie.tw. | ![image](https://hackmd.io/_uploads/ByWCmlxgC.png) <div style="page-break-after:always;"></div> ### 功能3 建立 Zone Records - subns.nasa.csie.tw | Name | Type | Status | TTL | Data | | ---- | ---- | ------ | ---- | --- | | @ | A | Active | 60 | 10.1.6.88 | ![image](https://hackmd.io/_uploads/B1qRElxlR.png) <div style="page-break-after:always;"></div>

    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