# Domain & DNS ## Week 1E ---- ## Domain Name 中文稱為網域名稱、網域或域名 因為 IP 不好記,所以找一個東西來代替 獨特、容易記憶且可以建立品牌形象 是一個成功的男人在 30 歲前應該擁有的東西 ---- ## 任務目標 把麥塊伺服器架在我要的 Domain 上 ---- ## DNS Domain Name System 用來紀錄網域名稱與 IP 對應的伺服器 `0ppai.dev` <=> `219.71.112.62` ---- ## 如何獲得網域 可以到 [Google Domains](https://domains.google.com/registrar/search) 購買 也可以到 [Cloudflare](https://www.cloudflare.com/zh-tw/products/registrar/) 購買 便宜的網域名稱一年約 $10 USD ---- ## 取得 IP 透過 `curl ifconfig.me` 或 `curl icanhazip.com` 我家的網路架構是 ISP > Router > PC 所以做個 Port Forwarding 就可以連到了 ---- ## 新增一個 A Record 可以使用 Google Domains 管理介面 ![](https://hackmd.io/_uploads/ryRqC-8Cn.png) ---- ## 解析域名工具 Linux 上可以使用 `nslookup` 或 `dig` 來查詢 ```bash= $ nslookup 0ppai.dev Server: 1.1.1.1 Address: 1.1.1.1#53 Non-authoritative answer: Name: 0ppai.dev Address: 219.71.112.62 ``` ---- ## 指定 DNS 常見的公開 DNS | 供應商 | 主要 DNS | 次要 DNS | |:---------- |:-------------- |:-------------- | | Google | 8.8.8.8 | 8.8.4.4 | | Cloudflare | 1.1.1.1 | 1.0.0.1 | | OpenDNS | 208.67.222.222 | 208.67.220.220 | ---- ## 新增一個 SRV Record 不能 Port Forwarding 的可以考慮用 Ngrok 但是記得幫麥塊伺服器開白名單 ![](https://hackmd.io/_uploads/BkPw1z8Cn.png) --- # Cloudflare ---- ## Introduction Cloudflare 是個有名的網路安全公司 提供 DNS, Proxy, 防止 DDoS 等功能 透過 CF 管理網域可以得到更好的保護 ---- ## 轉移到 Cloudflare 做管理 Cloudflare 可以做 Proxy 保護你的真實 IP 首先到 Google Domains 修改這項設定 ![](https://imgur.com/5zLjtBP.png) ---- ## 等待 Cloudflare 確認 到 Cloudflare 新增網站後點 Chech nameservers 這步驟要等一個小時才會完成 ![](https://imgur.com/BaYR2mq.png) ---- ## Cloudflare Proxy Cloudflare 的 DNS 自動提供 Proxy 功能 這樣別人 `nslookup` 就不會看到你的真實 IP ![](https://hackmd.io/_uploads/r1NaHutA2.png) 但不知為何會讓我沒辦法連上麥塊伺服器 把 Proxy 關掉後基本上就能跟麥塊伺服器連線了 ---- ## 設定網頁地圖 架設麥塊的 Dynmap 服務 可以透過瀏覽器觀看伺服器的大地圖 [Demo](https://map.0ppai.dev) ---- ## Service 基本資訊 會在 0.0.0.0:8123 架一個 HTTP Web Service 我們可以透過 Cloudflare 賞他一頓 HTTPS ---- ## Origin Rules 1. 設定一個 A Record 同樣指向我的 IP 2. SSL/TLS > Overview 選擇 Flexible 3. 到 CF > Rules > Origin Rules 設定如下: - Field: Hostname - Operator: Equal - Value: map.0ppai.dev - Destination Port: Rewrite to 8123 ---- ## 結論 - Domain Name 超帥 - Cloudflare 超好用 - 兔子超級佬
{"slideOptions":"{\"transition\":\"slide\"}","title":"Week 1E - Domain & DNS","description":"地獄貓旅行團第 30 週心得分享","contributors":"[{\"id\":\"c7cbb212-2c41-4dfa-8d85-f8e7fa769bf1\",\"add\":2428,\"del\":189}]"}
    219 views
   Owned this note