# 廣域網路 [TOC] # 期中考 :::warning **purposea目標:** In this lab, you will complete the following objectives: 1. Cable the Network and Verify the Default Switch Configuration 2. Configure Basic Network Device Settings 3. Verify and Test Network Connectivity 4. Manage the MAC Address Table * 可以設定多個獨立的網段 為了遠端作業,配交換機的IP位址與子網路遮罩 * Switch 2960設定ipv6前需要加一段指令 sdm prefer dual-ipv4-and-ipv6 default 然後再重新加載 ### SVI > Cisco的L3交換器上頭切割VLAN的時候,需要設定所謂的SVI,才能夠讓VLAN底下的電腦與其他VLAN進行溝通  #### 1.1 Switch SVI Configuration Example交換機SIV配置: :::info **第 1 步:** 配置管理接口:在 VLAN 接口配置模式下,將 IPv4 地址和子網掩碼應用於交換機的管理 SVI。  **copy running-config startup-config** 存檔 ::: :::info **第 2 步:** 配置默認網關  ::: :::info **第 3 步:** 驗證 **show ip interface brief** **show ipv6 interface brief**  ::: --- #### 1.2 Configure Switch Ports * 全雙工```duplex full```: * Full-duplex communication increases bandwidth efficiency by allowing both ends of a connection to transmit and receive data simultaneously. * There is **no collision domain associated** with a switch port operating in full-duplex mode. * 允許**同時發送和接收(雙向通信)**,會微分段 * 半雙工```duplex half``` * Half-duplex communication creates performance issues because data can flow in only one direction at a time, often **resulting in collisions**. * 只能單向通信,半雙工通信會產生性能問題,因為數據一次只能在一個方向上流動,通常會導致衝突。 * When **troubleshooting switch port issues**, it is important that the duplex and speed settings are checked. 交換機端口除錯時,**檢查雙工和速度設置很重要。** * ex.光纖:雙工&只有一種速度 :::info * 可以手動配置交換機端口與速度,實體配置交換機端口: **左右兩端口速度要一致**  * 設置好後要驗證/除錯 **``` show running-config```**  ::: --- #### 1.3 Secure Remote Access 安全的遠端路徑 * Telnet 是一種較舊的協議,使用不安全的明文傳輸登錄身份驗證(用戶名和密碼)和在通信設備之間傳輸的數據。 可以被Wireshark抓到帳號密碼 * Secure Shell ==**SSH**== 使用 TCP 端口 22 的安全協議。它提供與遠程設備的安全(加密)管理連接。 SSH provides security for remote connections by providing strong encryption when a device is authenticated (==**username** and **password**==) and also for the transmitted data between the communicating devices. 查看SSH狀態 **```show ip ssh``` ```show ssh```** * 查看網路的狀態 **```show ip interface brief ```**  ## 2.1 Frame Forwarding  * 交換機 是第二層的設備 ==乙太網路的訊框資料frame forwarding轉發== * 交換機根據入口接口和目標 MAC 地址進行轉發。 * 使用其 ==MAC 地址表== MAC address table(**紀錄PC實體位置與對應的阜號port**) 來做出轉發決策  ### Switch Forwarding Method交換機轉發的方式 * store and forward switching * 檢查全部的資料讀到CRC 確保正確 * 15200個 會延遲、目前不常見 因為設備進步了  * cut through switching * 讀到mac address 就傳送了  廣播📢 ## VLANs 減少廣播的範圍》》分割區段 不改變既有的網路拓撲圖就能分割區段 * 提升安全性 * 避免廣播互相撞牆 access mode trunk mode virtual lan number **VID** vid使用的方式: tagging在資料後面加入vid 不同的區網沒有路由器還是不會通  Switch 0>>trunk枝幹 ```protobuf! en config t host S0 vlan 10 vlan 20 vlan 30 int f0/1 vlan 99 name 99 exit int f0/1 switchport mode trunk switchport trunk native vlan 99 switchport trunk allowed vlan 10,20,30,99 end ``` Switch 1 & Switch 2 ``` en config t host S1 int f0/1 vlan 10 name 10 exit int f0/1 switchport mode access switchport access vlan 10 end ``` ## Router in stick  ### router: **在入口(default gateway)處再分段(vlan)**  ch4-p14 ``` ``` stp: ``` 網路上辨別一台電腦的方式是利用 IP,但是一組 IP 數字很不容易記,且沒有什麼聯想的意義,因此,我們會為網路上的伺服器取一個有意義又容易記的名字,這個名字我們就叫它「Domain Name」。但由於在 Internet 上真實在辨識機器的還是 IP,所以當使用者輸入Domain Name後,瀏覽器必須要先去一台有 Domain Name 和 IP 對應資料的主機去查詢這台電腦的 IP,而這台被查詣的主機,我們稱它為 Domain Name Server,簡稱 DNS,例如:當你輸入 www.twnic.com.tw時,瀏覽器會將www.twnic.com.tw這個名字傳送到離他最近的 DNS Server 去做辨識,如果詢找到,則會傳回這台主機的 IP,進而跟它索取資料 ``` ## DHCP 提供的服務: * 給ip * 遮罩 * 預設砸到 * DNS **Work_2**  * ==**路由器**== 作為中介,將左邊入口的ip位址轉送到DHCP Server,讓伺服器動態提供IP位址  * ==**Web(WWW) Server**== 給IP、設定DNS Server位址 * ==**DNS Server**== 將www變成IP位址給電腦看,給IP、網域&ip對照表  給定web伺服器網址,建立Domain name  * ==**DHCP Server**== 動態提供IP位址,將左邊的網段(192.168.10.X)設定,並設定範圍(去掉頭尾)  * ==**PC**== 開啟DHCP動態提供IP位址  最後開啟瀏覽器,確認是否能連到web伺服器  :dart: 下周考試router on stick/inser channel/DHCP --- # 期末考 ## endpoint security **末端的安全機制** 攻擊方式: * DDos分散式阻斷病毒 * Data Breach * Malware 保護措施: * VPN(virtual private network) * 次世代防火牆NGFW(最多可到第7層檢測) * NAC:A認證A帳戶(授權管理)A流量管制  :::info ```= //router的遠端登入 line vty 0 4 password cisco login ``` router的遠端登入(不安全) 改用SSH加密方式: ```= //router-SSH enable secret cisco line con 0 password cisco login ip domain-name example.com //限制僅此網域可連接 crypto key generate rsa eneral-keys modulus 2048 //加密的方法(密碼長度2048) username Zoe secret cisco//設定使用者名稱與密碼 ssh version 2 line vty 0 4 transport input ssh login local ``` PC測試登入: **ssl -L Zoe 192.168.10.1(routerIP)** ::: ## WAP2 personal Wireless Access Point 設定無線網路,讓平板上網  :::info 拓譜圖: 分成三個網段 * 192.168.1.0 * 192.168.2.0 * 192.168.3.0(無線WIFI) **路由器-網路AP 是同設備相接 要用虛線(下圖做錯了)**  1. AAA 伺服器設定 **認證與授權** >Authentication:帳號密碼登入的檢驗 Authorization :比喻來說論壇或者網站的管理和一般用戶的權限不同 Accounting :紀錄這個人是透過甚麼IP登入,他登入之後看了那些網頁,輸入甚麼指令、關鍵字等等 **服務的對象/192.168.2.2無線網路AP的IP(AP接路由器的端口)/密碼** 使用者名稱(待會平板要打的)/密碼  2. AP無線網路設定(GUI) * Iternet接到路由器 給ip位址192.168.2.2(接外網路由器的) default gatway路由器的ip * Network 外網(讓無線設備連接的網段) 設定範圍192.168.0.1  * 設定SSID(W-Fi 名稱)Service Set Identifier  * **RADIUS server(遠端使用者撥入驗證服務):AAA server的ip** * 設定密碼  * 完成後的樣子;確認Internet(連接路由器)、LAN(外網給平板連的)、Wireless(無線連接的方式)-WPA2+AAA serverIP+密碼  3. 平板 * 設定無線網路:輸入SSID與密碼 * 使用者登入:username、password  ::: :::info part2: **設定僅讓特定的電腦可用** 1. 改成disabled(不廣播)  2. 輸入可用的電腦的mac位址  ::: ### Configure IP Static Routes靜態路由 **自己建路由表,指定出口與網域** :::info  * R1: **```ip route 0.0.0.0 0.0.0.0 se0/0/0```** 加上連接外網的出口 * **因為只有一個連接外網出口 所以可以這樣打** **``ipv6 route ::/0 出口``** * R2: **```ip route 0.0.0.0 0.0.0.0 se0/0/0```** 加上連接外網的出口 * **因為只有一個出口,所以可以這樣打** * R3: ==**線接線直接連結的網路不用額外打**== **```ip route 172.16.3.0 255.255.255.0 se0/0/1```** **```ip route 右邊黃色的網段 遮罩 出口```** **```ipv6 route 承上一樣左右兩邊網段 出口```** ::: ### 動態路由RIP 啟動RIP(自動配位置), **找最短的(但雍塞沒辦法處理)** :::info  1. 設定網段ipv4 & ipv6 * A * 172.16.3.0| * PC:172.16.3.2| * router:172.16.3.1 * B * 172.16.1.0 | 2001:db8:acad:1::/64 * PC:172.16.1.2 | 2001:db8:acad:1::1/64 * router:172.16.1.1 |2001:acad:1::2/64 * C * 1 * 2 * 3 2. **ipv6 RIP** ```= ipv6 unicast-routing int g0/0 ipv6 add ... ipv6 enable no shut ipv6 rip process1 enable ``` 3. ipv4 RIP ```c= router rip version 2 network 172.16.3.0 //路由器有連接的所有網段 network 172.16.2.0 //ex.for R1 A、B、C、1、2、3總共6個網段都要打 ``` **```show ip route```** 看路由表(出口與ip位址來除錯 C、L:直接連接的網段 S:遠端連接 O:ospf **```show ip route int brief```** 顯示出口的協定 ::: ## OSPF 斷線自動找 **不雍塞** 的最快路徑 #### singlearea OSPFv2 :::info  ```c= //R3 router ospf 10//三台都是10(群組號碼) router-id 3.3.3.3//每台都不一樣R1:1.1.1.1 ... //同一個area下,直接連接外面的網段(接線的出口): network 172.16.2.1 0.0.0.0 area 0 //路由器的出口+遮罩 network 172.16.3.2 0.0.0.0 area 0 network 172.16.10.9 0.0.0.0 area 0 exit ``` ::: #### multiarea OSPFv2 大型企業、多顆路由器時使用 ==設定不同的area 號碼== ; **router之間連接的網段都用area 0** :::info 以ipv6為例:  ```c= //R1 ipv6 unicast-routing ipv6 ospf 10 //還是一樣的環境(所以都是10) router-id 1.1.1.1 int se0/0/0 //所有出口都要 ipv6 ospf 10 area 0 //area 號碼(對應的連接區) int se0/0/1 ipv6 ospf 10 area 0 int g0/1 ipv6 ospf 10 area 1 int g0/0 ipv6 ospf 10 area 1 ``` ::: ## ACL **路由器的防火牆** ,可以對內控制封包的送出,對外過濾封包的進入。 有兩種模式 **(標準式/延伸式)** ,是兩種不同的規定、要分別設定。 * 標準式 * 延伸式 可以用 **序號或是命名** 來使用ACL。 * 序號 * 命名 >The last statement of an ACL is always an implicit deny. This statement is automatically inserted at the end of each ACL even though it is not physically present. The implicit deny blocks all traffic. Because of this implicit deny, an ACL that does not have at least one permit statement will block all traffic  * 設在出口的介面處,分別對 **封包出去(out)與進入(in)** 做監測。 * ACL條件 **判斷是由上而下** ,最先輸入的優先權最高, 打完後要輸入(讓其他可通過) ==**```permit ip any any```**==,不然預設會讓所有都不通過。 --- ### Standard ACLs 標準式 * **標準式ACL基於源地址,要 ==放在目的端==** ,如果放在來源端口會擋全部要出去的封包  * 編號可用範圍1~99 /1300~1999 :::info **Standard ACLs** 對象改成192.168.11.0 - 192.168.31.0,其他依照拓譜圖  ```c=! //R3 //網段承上 int g0/1 access-list 1 deny 192.168.11.0 0.0.0.255 192.168.31.0 0.0.0.255 access-list 1 permit ip any any int g0/1 ip access-group 1 out//不能出去out ``` ::: --- ### Extended ACLs 延伸式 * 延伸式ACL基於以下幾個屬性過濾 IP 包:**==放在來源端==** * 來源IP和目標 IP 地址 * 來源和目標 **TCP 和 UDP 端口** * **協議類型/協議編號(例如:IP、ICP、UDP、TCP等)** * 編號103的ACL允許 **192.168.30.0~192.168.30.255這個網段** (因為遮罩是**0.0.0.255最後一碼不看** ) 到任何端口都允許上網 **(http協定80 or 443埠)**  * 編號可用範圍100~199 /2000~2699 * **```access-list number permit/deny 協定 來源ip 遮罩 目的ip 遮罩 eq 埠號```** * 比標準式更多了可設定==協定==、==eq 埠號== :::info **Extended ACLs** 1. PC3改成FTP server 2. PC4改成WWW server 3. PC2無法連到FTP server、並擋遠端登入telnet 4. PC1無法連到WWW server 5. 新增R1-R3直接連結的網段,開啟OSPF  **延伸式放在來源端** ```c= //R1 //PC1-WWW access-list 100 tcp deny 192.168.10.0 0.0.0.255 192.168.31.2 0.0.0.0 eq 80 access-list 100 tcp deny 192.168.10.0 0.0.0.255 192.168.31.2 0.0.0.0 eq 443 access-list 100 permit ip any any exit int g0/0 ip access-list 100 in //PC2-FTP access-list 101 tcp deny 192.168.11.0 0.0.0.255 192.168.30.2 0.0.0.0 eq ftp access-list 101 tcp deny 192.168.11.0 0.0.0.255 192.168.30.2 0.0.0.0 eq telnet access-list 101 permit ip any any exit int g0/1 ip access-list 101 in ``` ::: :::info **Extended ACLs to ICMP** 1. 讓192.168.11.0的網段不能到192.168.31.0 擋ping跟tracertout(**ICMP協定**): //如果之前有設定acl,要取另外的群組號碼;或整組刪掉順序要改(any any在最後不然都會通) 2. 增加R1和R3直接連結的網段,開啟ospf  **放在R1的g0/1出口(來源端)** ```c=! //R1 //網段承上 int g0/1 access-list 100 deny ICMP 192.168.10.0 0.0.0.255 192.168.31.0 0.0.0.255 access-list 100 permit ip any any int g0/1 ip access-group 100 in//不能進路由器 in ``` ::: --- * Numbered ACLs: 用編碼區分ACL * Named ACLs: 給ACL命名 **```ip access-list acl_name```**  :::info **Named ACLs**  1. 192.168.11.0 - 192.168.31.0 擋Telnet 2. 增加R1-R3直接連結的網段,開OSPF  ```c= //R1 ip access-list standard/extended acl_name //選擇方式 命名 deny tcp 192.168.11.0 0.0.0.255 192.168.31.0 0.0.0.255 eq telnet //就少了前面的access-list number permit ip any any exit int g0/0 ip access-group acl_name in //access-list 換成access-group exit ``` ::: ---- :::info **OSPF_Extended Named ACLs_IPV6**  ```c= //ospf ipv6 ipv6 unicast-routing ipv6 router ospf 10 router-id 1.1.1.1 //進到出口的介面 輸入對應的area號碼 int g0/0 ipv6 ospf area 10 ```  ``` ipv6 access-list name//命名 deny tcp any 2001:DB8:cafe:11::/64 eq 80 deny tcp any 2001:DB8:cafe:11::/64 eq 443 permit.. //進介面 //宣告in 還是out ipv6 traffic-filter name out ``` ``` R2(config)#ip access-list extend nonono R2(config-ext-nacl)# deny tcp 198.168.0.0 0.0.0.255 200.41.2.3 0.0.0.0 eq 80 R2(config-ext-nacl)# deny tcp 198.168.0.0 0.0.0.255 200.41.2.3 0.0.0.0 eq 443 R2(config-ext-nacl)#permit ip any any R2(config-if)#exit R2(config)#int g0/1 R2(config-if)#ip access-group nonono out R2(config-if)#exit ``` ::: ## 模擬考  * ospf * AAA * 命名式extend的 ACL擋80 443阜 * WPA2 企業版 webserver擋無線的網路(無線的開不起瀏覽器),但平板ping得到web server 多個孔: 
×
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