--- title: 網路課 week2 筆記 tags: 網路課tcp/ip --- # 網路課 week2 筆記 1. http://b23.tv/YWeVden 學習如何抓封包後,進行解析,如果想把通訊協定學得更好,可以看看怎樣寫程式分析的  ### ipv4 分為 ABC類 網路位置(192.168.1.0) 廣播位置(192.168.1.255) 不能給主機用 我果是有連網的網路 內定路由器位置(通常是192.168.1.1 or 192.168.1.254) 也不能給一般的電腦使用 D類 給群播(multicast)用 E類 保留位址 ### 以可不可以連上網路分類 可以連到網際的稱為public ip address, 反之稱為private ip address #### private ip address class A 10.0.0.0/8 (10.0.0.0 ~ 10.255.255.255) 保留下來作私有網路的ip使用的 class B 172.16.0.0/12 (172.16.0.0 ~ 172.31.255.255) class C 192.168.0.0/16 (192.168.0.0 ~ 192.168.255.255) A類的第一個網域 0.0.0.0 1. 本網域 ex: 通訊的位置為0.0.0.123 要與相同網路的123節點進行通訊 2. 電腦剛開機需要向DHCP伺服器請求一個可用的IP 以0.0.0.0代表尚未取得IP 3. 代表機器上任一個介面的位置(常用) **判斷是 公有 還是 私有 IP** 172.31.1.1 私有(B類) 172.32.1.1 公有 ### windows下 本地端查看電腦開啟了那些埠號 使用`findstr` 來過濾 > netstat -an | findstr TCP | LISTENING > netstat -an | findstr ESTABLISHED ### linux下 查看 (以TCP為例) > netstat -tulnp t : tcp, u : udp, l : listen, n : 不解析, p : 程式的process id --- ### NAT(Network Acess Translation) DNAT  ---- SNAT - 1->1(紅色、綠色) 只有改變IP SNAT - NAPT(藍色、黑色) 改變IP和Port, 只需要一個對外的IP 節省IP的應用比較容易  --- ### 迴路回測(Loop Back Test) 每台電腦都有Loop Back的virtual interface通常稱為LO 保留127.0.0.1給Loop Back使用 IPv4下 > ping 127.0.0.1 若失敗代表 OS裡的TCP/IP協定層出現問題 IPv6下 > ping -6 ::1 LO可以有很多個 RTT(round trip time) 封包來回時間 是測量網路效能重要的指標 若PTT過長 可能原因 1. 網路壅塞 2. 伺服器繁忙 OWD(one way delay) 送出封包到接收到的時間差 也是測量網路效能重要的指標 1. OWD短RTT長 伺服器忙碌 2. OWD長RTT長 網路壅塞 --- ### 區域廣播(Local Broadcast) 位置 255.255.255.255 --- ### DHCP(Dynamic Host Configuration Protocol)動態主機設定協定 使用時機:網路自動化設定 DHCP 也是客戶端伺服器端的模型 客戶端使用68埠 伺服器端使用67埠 DHCP伺服器必需要提供客戶以下資訊才能聯絡 1. IP 2. Mask (判斷對方是否在同個網路, 相同的話直接傳 不同的話使用內定路由器傳) 3. default-router (內定路由器傳) 4. DNS server 可提供tftp server 用處:重灌電腦教室的多台電腦 1. 在BIOS選用網路開機 2. 先去DHCP server取得上述4種資訊 3. 發現本地端沒有開機的資訊 4. 到tftp server OS抓回去 搭配腳本自動安裝 運作的原則 DORA  在windows上查看DHCP server資訊 > ipconfig/all --- ### DNS(Domain Name System) 正向解析 domain name 跟 IP 轉換 反向解析 IP 跟 domain name 轉換 (可用來查看 看我的網站的人 在哪個國家) **使用UDP(53埠) 快 但是 不安全** 最常受到 DDOS(分散式阻斷攻擊) 應用 CDN(Content delivery network) 傳統上使用IP做資料存取 有些時候較沒效率 CDN是以內容進行傳輸作為導向的網路 原理:DNS的高級設定 透過不同的IP給予不同的回答 windows下hosts.txt位置 > $ C:\Windows\System32\drivers\etc\hosts. linux下 > $ \etc\hosts ``` # Copyright (c) 1993-2009 Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windows. # # This file contains the mappings of IP addresses to host names. Each # entry should be kept on an individual line. The IP address should # be placed in the first column followed by the corresponding host name. # The IP address and the host name should be separated by at least one # space. # # Additionally, comments (such as these) may be inserted on individual # lines or following the machine name denoted by a '#' symbol. # # For example: # # 102.54.94.97 rhino.acme.com # source server # 38.25.63.10 x.acme.com # x client host # localhost name resolution is handled within DNS itself. # 127.0.0.1 localhost # ::1 localhost 0.0.0.1 mssplus.mcafee.com ``` 若要進行解析(步驟如下) 1. hosts.txt 2. cache `$ ipconfig/displaydns` 如果要清除cache 使用`$ ipconfig/flushdns` 4. DNS server --- ### FQDN(Fully Qualified Domain Name) 網域完整的名字 規則: 1. 以 . 間隔層級 2. 最多 5 個層級 (重要) 3. 每一級最少2個字元, 小於63格字元 4. 總長 < 253字元 (重要) 5. 可用英文、數字、破折號、中文... FQDN 包含: 1. Host Name 2. Domain Name 3. 根網域 . ex: www.flag.com.tw.  ---
×
Sign in
Email
Password
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