300 likes | 513 Views
實驗二 基本網路命令的使用. ping 、 traceroute 、 ipconfig 、 arp 與 netstat 的使用. 大綱. 學習目標 實驗設備與材料 背景知識 實驗步驟 實驗報告 成績計算. 學習目標. 認識網路上常用的工具程式。 學習 ipconfig 、 ping 、 traceroute 、 natstat 、 arp 等網路工具程式。 Windows 提供線上查詢服務,例如想得到更多關於 ping 的使用方式,可以鍵入下面命令,便可獲得更多的操作方式。. 實驗設備與材料. Cisco2620 1 台 +Cisco 1700 2 台
E N D
實驗二 基本網路命令的使用 ping、traceroute、ipconfig、arp 與 netstat 的使用
大綱 • 學習目標 • 實驗設備與材料 • 背景知識 • 實驗步驟 • 實驗報告 • 成績計算
學習目標 • 認識網路上常用的工具程式。 • 學習ipconfig、ping、traceroute、natstat、arp等網路工具程式。 • Windows提供線上查詢服務,例如想得到更多關於ping的使用方式,可以鍵入下面命令,便可獲得更多的操作方式。
實驗設備與材料 • Cisco2620 1台+Cisco 1700 2台 • 1台telnet server • 四人一組為原則,以小組為單位進行實驗與繳交實驗報告。 • 2-4人PC 1台
s0/2 s0/0 R3 e0/0 s0/3 s0/1 R4 s0/0 s0/0 R5 e0/0 e0/0 Topology of Lab Network Telnet server
3個區域網路 • 192.168.1.x/24 • 三台電腦的IP address請設為192.168.1.1,192.168.1.2,192.168.1.3 • 192.168.2.x/24 • 192.168.2.1,192.168.2.2,192.168.2.3 • 192.168.7.x/24 • 192.168.7.1,192.168.7.2,192.168.7.3
指令 • ping 用於詢問對方的主機是否存在 • ipconfig 用於詢問本機所有的網路介面的設定資訊 • tracert 用於詢問到對方主機的路徑 • arp 用於查表獲得同一網路上對方的主機的 MAC address • netstat 用於詢問本機所有的網路介面的使用狀態
指令使用方式的On-line Help • ping.txt 與 ipconfig.txt(在command mode下以ipconfig /?命令尋求online help) • 可用下面I/O轉向的方式記錄下ping等軟體的使用過程 • ping 192.168.1.4 > aaa • type aaa
ping 的範例 C:\>ping 140.138.137.224 Pinging 140.138.137.224 with 32 bytes of data: Reply from 140.138.137.224: bytes=32 time=160ms TTL=245 Reply from 140.138.137.224: bytes=32 time=60ms TTL=245 Reply from 140.138.137.224: bytes=32 time=240ms TTL=245 Reply from 140.138.137.224: bytes=32 time=80ms TTL=245 Ping statistics for 140.138.137.224: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 60ms, Maximum = 240ms, Average = 135ms
ping 的用法 (1/2) Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] destination-list Options: -t Ping the specified host until stopped. To see statistics and continue - type Control-Break; To stop - type Control-C. -a Resolve addresses to hostnames. -n count Number of echo requests to send. -l size Send buffer size. -f Set Don't Fragment flag in packet.
ping 的用法 (2/2) Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] destination-list Options: -i TTL Time To Live. -v TOS Type Of Service. -r count Record route for count hops. -s count Timestamp for count hops. -j host-list Loose source route along host-list. -k host-list Strict source route along host-list. -w timeout Timeout in milliseconds to wait for each reply.
ipconfig 的範例 (1/2) C:\>ipconfig Windows 2000 IP Configuration Ethernet adapter Wireless LAN: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.1.4 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 Ethernet adapter 區域連線: Media State . . . . . . . . . . . : Cable Disconnected
ipconfig 的範例 (2/2) • 在 DHCP 的環境下,先使用 ipconfig /release 後, 觀察 ipconfig /all. 再用 /renew 獲得新的 IP,以 /all 觀察.
ipconfig 的用法 (1/4) Windows 2000 IP Configuration USAGE: ipconfig [/? | /all | /release [adapter] | /renew [adapter] | /flushdns | /registerdns | /showclassid adapter | /setclassid adapter [classidtoset] ] adapter Full name or pattern with '*' and '?' to 'match', * matches any character, ? matches one character.
ipconfig 的用法 (2/4) Options /? Display this help message. /all Display full configuration information. /release Release the IP address for the specified adapter. /renew Renew the IP address for the specified adapter. /flushdns Purges the DNS Resolver cache. /registerdns Refreshes all DHCP leases and re-registers DNS names /displaydns Display the contents of the DNS Resolver Cache. /showclassid Displays all the dhcp class IDs allowed for adapter. /setclassid Modifies the dhcp class id.
ipconfig 的用法 (3/4) The default is to display only the IP address, subnet mask and default gateway for each adapter bound to TCP/IP. For Release and Renew, if no adapter name is specified, then the IP address leases for all adapters bound to TCP/IP will be released or renewed. For SetClassID, if no class id is specified, then the classid is removed.
ipconfig 的用法 (4/4) Examples: > ipconfig ... Show information. > ipconfig /all ... Show detailed information > ipconfig /renew ... renew all adapaters > ipconfig /renew EL* ... renew adapters named EL.... > ipconfig /release *ELINK?21* ... release all matching adapters, eg. ELINK-21, myELELINKi21adapter.
tracert 的範例 C:\>tracert 140.138.137.224 Tracing route to 140.138.137.224 over a maximum of 30 hops 1 <10 ms 10 ms <10 ms 192.168.1.1 2 <10 ms 10 ms <10 ms h222-210-66-38.seed.net.tw [210.66.38.222] 3 70 ms 70 ms 70 ms 172.28.12.89 4 70 ms 70 ms 70 ms R37-125.seed.net.tw [139.175.37.125] 5 70 ms 70 ms 70 ms R58-97.seed.net.tw [139.175.58.97] 6 71 ms 80 ms 70 ms R58-150.seed.net.tw [139.175.58.150] 7 70 ms 70 ms 71 ms R56-126.seed.net.tw [139.175.56.126] 8 70 ms 70 ms 80 ms 203.71.2.237 9 70 ms 80 ms 81 ms 140.138.7.2 10 70 ms 81 ms 80 ms 140.138.7.10 11 70 ms 70 ms 80 ms 140.138.191.18 12 190 ms 280 ms 171 ms 140.138.137.224 Trace complete.
tracert 的用法 Usage: tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] target_name Options:-dDo not resolve addresses to hostnames.-h maximum_hopsMaximum number of hops to search for target.-j host-listLoose source route along host-list.-w timeoutWait timeout milliseconds for each reply.
arp 的範例 • Address Resolution Protocol Interface: 192.168.2.112 on Interface 0x1000003 Internet Address Physical Address Type 192.168.2.1 00-d0-b7-23-eb-2f dynamic 192.168.2.254 00-90-fb-a1-45-79 dynamic • 使用 arp –d 先刪除所有 table 中的資訊, 在用 ping 找任何一台機器, 之後再觀察 arp –a。
arp 的用法 (1/2) Usage: ARP -s inet_addr eth_addr [if_addr]ARP -d inet_addr [if_addr]ARP -a [inet_addr] [-N if_addr] Options:-aDisplays current ARP entries by interrogating the current protocol data. If inet_addr is specified, the IP and Physical addresses for only the specified computer are displayed. If more than one network interface uses ARP, entries for each ARP table are displayed. -gSame as -a.inet_addrSpecifies an internet address.-N if_addrDisplays the ARP entries for the network interface specified by if_addr.
arp 的用法 (2/2) -DDeletes the host specified by inet_addr. -SAdds the host and associates the Internet address inet_addr with the Physical address eth_addr. The Physical address is given as 6 hexadecimal bytes separated by hyphens. The entry is permanent. Eth_addrSpecifies a physical address.If_addr If present, this specifies the Internet address of the interface whose address translation table should be modified. If not present, the first applicable interface will be used.
netstat 的範例 (1/2) C:\>netstat -e Interface Statistics Received Sent Bytes 1670417 2298060 Unicast packets 6553 6724 Non-unicast packets 116 68 Discards 0 0 Errors 0 0 Unknown protocols 0
netstat 的範例 (2/2) • 使用 netstat –a –n | more 看 active connections 資料,| more 代表一次看一頁,-n 代表用數字表示。 1. 看 netstat –e各個options 2. 嘗試建立新連線. 可以使用 telnet 127.0.0.1 135 (note: 135是網路芳臨)。 3. 看 netstat會發現多兩筆資料,one output,one input。
netstat 的用法 (1/2) Usage: NETSTAT [-a] [-e] [-n] [-s] [-p proto] [-r] [interval] Options:-aDisplays all connections and listening ports.(Server-side connections are normally not shown).-eDisplays Ethernet statistics. This may be combined with the -s option.-nDisplays addresses and port numbers in numerical form.-p protoShows connections for the protocol specified by proto; proto may be tcp or udp. If used with the -s option to display per-protocol statistics, proto may be tcp, udp, or ip.-rDisplays the contents of the routing table.
netstat 的用法 (2/2) -sDisplays per-protocol statistics. By default, statistics are shown for TCP, UDP and IP; the -p option may be used to specify a subset of the default.IntervalRedisplays selected statistics, pausing interval seconds between each display. Press CTRL+C to stop redisplaying statistics. If omitted, netstat will print the current configuration information once.
個人實驗步驟 (1/2) • 設定your PC,並繪製出實驗室架構。 • Ex: IP address、Network Mask、Default Gateway… • 使用arp指令,找出其他在同一個LAN上的PC的MAC address。
個人實驗步驟 (2/2) • 使用netstat指令,觀察網路使用狀況。 • netstat –s –p ICMP ping 140.138.173.34 netstat –s –p ICMP • netstat –s –p TCP 使用putty連到140.138.173.34 輸入多次netstat –s –p TCP 結束putty連線netstat –s –p TCP • netstat –s –p UCP telnet pcs.eed.yzu.edu.tw netstat –s –p UCP • 使用tracert,繪製出實驗室架構。
分組實驗步驟 • 請利用ping、traceroute繪製出學校的網路架構。並列舉說明繪製網路架構的指令使用方式。 • 設計實驗以說明ping、traceroute、ipconfig、arp 與 netstat 所有option的用法及每個欄位的意義。 Ex: 利用netstat –s 觀察 IP、ICMP、TCP、UDP的使用統計數據並說明之。例如 ping 前後的 ICMP 的使用狀況。
成績計算 • 個人實驗部分當場交,做為一次實驗成績。 • 每組繪製學校網路架構,做為一次實驗成績。 • 依完整程度給分 • 同組同學將有相同的分數。