# NASA HW04
學生鍾詠傑
學號41173058H
<div style="page-break-after:always;"></div>
## 1. 迷星叫
### 1.
在 Cisco Switch 上我們可以指定一個埠口為 Access Port 或者 Trunk Port,請問這兩者有什麼差異,請完成下列表格。
| | 可通過的 VLAN 數量 | 802.1Q 標記 |
| - | - | - |
| Access Port | 僅限於一個 VLAN | 不進行 802.1Q 標記 |
| Trunk Port | 可通過多個 VLAN | 進行 802.1Q 標記 |
<div style="page-break-after:always;"></div>
### 2.
請問何謂 Trunk Native VLAN?
Trunk Native VLAN 是指在一個 Trunk Port 上,未標記(即未打上 802.1Q 標籤)的封包所屬的 VLAN。
當封包從 Trunk Port 進入或離開交換機時,如果封包未標記,則交換機將其視為屬於 Trunk Native VLAN。
通常情況下,交換機的 Trunk Native VLAN 與管理人員設置的其他 VLAN 是分開的。
這樣做的目的是為了確保 Trunk Port 能處理未標記的封包,以及在需要時能夠區分它們屬於哪個 VLAN。
<div style="page-break-after:always;"></div>
### 3.
| 傳遞方向 | 線路 1 | 線路 2 | 線路 3 | 線路 4 | 線路 5 | 能否抵達 |
| -------- | ------ | ------ | ------ | ------ | ------ | ---- |
| PC-01/VLAN 10 → PC-02 |10|10||||可|
| PC-01/VLAN 20 → PC-02 |20|X||||否|
| PC-01/VLAN 10 → PC-04 |10||無||X|否|
| PC-01/VLAN 20 → PC-04 |20||20||20|可|
| PC-01/VLAN 10 → PC-03 |10|||10||可|
| PC-01/VLAN 20 → PC-03 |20|||20||可|
<div style="page-break-after:always;"></div>
### 4.
在這個網路中有機會能透過 Double Tagging Attack 從 PC-01/VLAN 10 傳送到 PC-04。
PC-01 的 VLAN 10 封包通過 Trunk Port 發送到 switch-01,然後通過帶有 VLAN 10 和 VLAN 20 的 Trunk 連接發送到 switch-02。然而,在 switch-01 到 switch-02 的 Trunk 連接上,VLAN 10 被設定為 Native VLAN。
Native VLAN 是在 Trunk 連接上未打上 VLAN 標籤的默認 VLAN,
但在這個情況下,switch-01 將 Native VLAN 設置為 VLAN 10。
由於 VLAN 10 是 Native VLAN,因此從 switch-01 到 switch-02 的 Trunk 連接上傳輸的 VLAN 10 封包將不會被打上 VLAN 標籤。因此,當這些不帶 VLAN 標籤的封包到達 switch-02 時,switch-02 將會將它們視為屬於其本地 VLAN 20(即目標 VLAN)的封包進行處理。
所以 PC-01 發送的 VLAN 10 封包在特定情況下能夠發送到 PC-02 。
<div style="page-break-after:always;"></div>
## 2. 春日影
### part1
密碼有以下
```
enable secret 5 $1$mERr$xOBRtHD8zJf.94CGVuvjw/
username RiNG privilege 15 password 7 0813435D0C150C16
```
一種是Cisco的Type 7加密形式,一種是Type 5加密形式。
前者是Cisco自己的加密形式,存在多年,但是這種加密方式很簡單,是可以進行破解的。
後者相當於MD5加密,是無法被破解的。
透過 0813435D0C150C16 經過解密工具
可以知道密碼是`Roselia`
工具:
https://www.firewall.cx/cisco/cisco-routers/cisco-type7-password-crack.html
<div style="page-break-after:always;"></div>
### part2
建立VLAN 20,30
將 Fa0/1-3 規劃到 Vlan 20 設定為access,
將 Fa0/11-12 規劃到 vlan 30 設定為access,
```
RiNG-Core(config)#vlan 20
RiNG-Core(config-vlan)#exit
RiNG-Core(config)#vlan 30
RiNG-Core(config-vlan)#exit
RiNG-Core(config)#interface range fastEthernet 0/1-3
RiNG-Core(config-if-range)#switchport access vlan 20
RiNG-Core(config-if-range)#exit
RiNG-Core(config)#interface range fastEthernet 0/11-12
RiNG-Core(config-if-range)#switchport mode access
RiNG-Core(config-if-range)#switchport access vlan 30
RiNG-Core(config-if-range)#exit
```
RiNG-Edge 中
建立Vlan 20 並
將 Fa0/21-22 規劃到 Vlan 20 設定為access
```
RiNG-Edge(config)#vlan 20
RiNG-Edge(config-vlan)#exit
RiNG-Edge(config)#interface range fastEthernet 0/21-22
RiNG-Edge(config-if-range)#switchport mode access
RiNG-Edge(config-if-range)#switchport access vlan 20
RiNG-Edge(config-if-range)#exit
```
以下設定在RiNG-Core RiNG-Edge 中都有做
刪除vlan 10
```
RiNG-Core# configure terminal
RiNG-Core(config)#
RiNG-Core(config)# no vlan 10
```
改名vlan 20 30
```
RiNG-Core(config)#vlan 20
RiNG-Core(config-vlan)#name VLAN-MyGO
RiNG-Core(config-vlan)#exit
RiNG-Core(config)#vlan 30
RiNG-Core(config-vlan)#name VLAN-AveMujica
RiNG-Core(config-vlan)#exit
```
將swithc 0-1 中 Gi 0/1-2 設為 port-channel 開啟 Trunk模式
```
### Trunk : 多個 VLAN
RiNG-Core(config)# interface GigabitEthernet 0/1-2 // specify interface
RiNG-Core(config-if-range)# switchport mode trunk // force mode TRUNK
RiNG-Core(config-if-range)# switchport trunk allowed vlan 20,99
RiNG-Core(config-if)# exit
// 1. add physical ports into port channel
RiNG-Core(config-if)# interface range GigabitEthernet 0/1-2
RiNG-Core(config-if-range)# channel-group 1 mode active
RiNG-Core(config-if-range)# exit
// 2. create a new port channel
RiNG-Core(config)# interface port-channel 1
RiNG-Core(config-if)# switchport mode trunk
RiNG-Core(config-if)# switchport trunk allowed vlan 20,99
RiNG-Core(config-if)# exit
```
<div style="page-break-after:always;"></div>
### part3
#### 調整帳號 RiNG 的密碼為 secret 模式,且更改密碼為 Afterglow
如過對兩個密碼使用相同的用戶名
所以我採取以下措施:
添加帶有秘密密碼的新用戶<<-這作為備份,以防刪除舊用戶名後無法存取任何內容。
刪除舊的用戶名命令,然後使用秘密密碼再次添加它。
以下設定在 RiNG-Core 跟 RiNG-Edge 中的做法一樣
```
RiNG-Core(config)#username RiNG_backup secret Roselia
RiNG-Core(config)#exit
RiNG-Core#
RiNG-Core#write memory
Building configuration...
[OK]
RiNG-Core#configure terminal
RiNG-Core(config)#no username RiNG
RiNG-Core(config)#exit
RiNG-Core#write memory
Building configuration...
[OK]
RiNG-Core#conf t
RiNG-Core(config)#username RiNG secret Afterglow
RiNG-Core(config)#no username RiNG_backup
RiNG-Core(config)#exit
RiNG-Core#write memory
Building configuration...
[OK]
```
#### 啟動 RiNG-Core 的 Telnet/SSH 登入
這部分 RiNG-Edge 不用做
```
RiNG-Core(config)# ip domain-name Ring_Core
RiNG-Core(config)# crypto key gen rsa
輸入1024
```
#### 設定 RiNG-Core 和 RiNG-Edge 的 vty 0-4 都可以使用 (a) 的帳密且只能透過 SSH 登入
```
RiNG-Core(config)# line vty 0 4
RiNG-Core(config-line)# transport input ssh
RiNG-Core(config-line)# login local
```
#### 設定 RiNG-Core 和 RiNG-Edge 的 vty 5-15 都無法登入
```
RiNG-Core(config)# line vty 5 15
RiNG-Core(config-line)# transport input none
```
#### 設定 RiNG-Core 和 RiNG-Edge 的 SSH 版本為 v2
```
RiNG-Core(config)# ip ssh version 2
RiNG-Core(config)# do wr //儲存
```
<div style="page-break-after:always;"></div>
## 3. 無路矢
### 1.

以上是經過手動/release /renew 之後,使用Wireshark觀察手動filter DHCP
在使用Wireshark來觀察通過DHCP協定自動取得網路組態的過程時,我們可以觀察到以下四個階段,也就是DORA:
1. **Discover (尋找):** 在這個階段,客戶端(即你的電腦)向網絡中的DHCP伺服器發送尋找請求。這個尋找請求是一個廣播消息,目的是尋找可用的DHCP伺服器。
2. **Offer (提供):** DHCP伺服器收到尋找請求後,如果有可用的IP地址和設定資訊,就會向客戶端發送一個提供消息。這個消息包含了IP地址、子網掩碼、網關等資訊。
3. **Request (請求):** 客戶端收到一個或多個提供消息後,會從中選擇一個提供消息,然後向該DHCP伺服器發送一個請求消息,表示接受該伺服器提供的設定資訊。
4. **Acknowledge (確認):** DHCP伺服器收到請求消息後,會向客戶端發送一個確認消息,表示客戶端可以開始使用提供的IP地址和設定資訊了。
這四個階段共同構成了DHCP的過程,使得客戶端可以自動獲得網路設定資訊,而無需手動設定。
<div style="page-break-after:always;"></div>
### 2.
在DHCP Discover階段中,以下是特殊的IP/MAC地址以及它們的含義:
- **IP 0.0.0.0**:
- 涵義:表示客戶端尚未擁有有效的IP地址。
- 原因:在DHCP Discover階段,客戶端尚未獲得有效的IP地址,因此它在尋找可用的DHCP伺服器時使用0.0.0.0作為源IP地址。
- **IP 255.255.255.255**:
- 涵義:表示廣播地址,用於將消息發送到網絡中的所有主機。
- 原因:在DHCP Discover階段,客戶端尋找可用的DHCP伺服器,因此將尋找請求消息廣播到網絡中的所有主機,以便任何可用的DHCP伺服器都能接收到。
- **MAC FF:FF:FF:FF:FF:FF**:
- 涵義:表示廣播MAC地址,用於將消息發送到網絡中的所有主機。
- 原因:與IP 255.255.255.255相似,在以太網中,MAC地址FF:FF:FF:FF:FF:FF是一個特殊的廣播地址,它將消息發送到網絡中的所有主機,以便任何可用的DHCP伺服器都能接收到尋找請求消息。
在DHCP Discover階段,使用這些特殊地址可以確保所有的DHCP伺服器都能收到尋找請求訊息(對所有人請求)
<div style="page-break-after:always;"></div>
### 3.
以下是對RiNG-Core 進行 dhcp snooping 的方式
並對FA0/22設定為信任(預設為否)
```
RiNG-Core#conf terminal
Enter configuration commands, one per line. End with CNTL/Z.
RiNG-Core(config)#ip dhcp snooping vlan 1
RiNG-Core(config)#in
RiNG-Core(config)#interface fa
RiNG-Core(config)#interface fastEthernet 0/22
RiNG-Core(config-if)#ip dh
RiNG-Core(config-if)#ip dhcp s
RiNG-Core(config-if)#ip dhcp snooping t
RiNG-Core(config-if)#ip dhcp snooping trust
RiNG-Core(config-if)#exit
```
Ref:
https://www.youtube.com/watch?v=2eNsoS9Ri6w&ab_channel=NorthwoodsPS
<div style="page-break-after:always;"></div>
## 指令備份
### mode
```
meow> // user EXEC
meow> enable
meow# // privileged EXEC
meow# configure terminal
meow(config)# // global configuration
meow(config)# interface GigabitEthernet 1/0/1
meow(config-if)# // interface configuration
meow(config-if)# exit
meow(config)# // global configuration
meow(config)# exit
meow# // privileged EXEC
meow# disable
meow> // user EXEC
```
### VLAN
```
meow(config)# vlan 99 // create a vlan
meow(config-vlan)# exit
```
### Access : 單一 VLAN
```
meow(config)# interface FastEthernet 1/0/1 // specify interface
meow(config-if)# switchport mode access // force mode ACCESS
meow(config-if)# switchport access vlan 123
meow(config-if)# exi
```
### Trunk : 多個 VLAN
```
meow(config)# interface GigabitEthernet 1/0/2 // specify interface
meow(config-if)# switchport mode trunk // force mode TRUNK
meow(config-if)# switchport trunk allowed vlan 1-10,123
meow(config-if)# exit
```
### Port Channel : 多個 Port
```
// 1. add physical ports into port channel
meow(config-if)# interface range GigabitEthernet 1/0/1-4
meow(config-if-range)# channel-group 1 mode active
meow(config-if-range)# exit
// 2. create a new port channel
meow(config)# interface port-channel 1
meow(config-if)# switchport mode trunk
meow(config-if)# switchport trunk allowed vlan 1-10,123
meow(config-if)# exit
```
### other
```
meow# copy running-config startup-config // method 1
meow# write memory // method 2
meow(config)# do wr
```
```
meow# show ... // in privileged EXEC
meow(config)# do show ... // at or above global configuration
```
###
{"title":"NASA HW04","contributors":"[{\"id\":\"8db22c7a-01d1-4d31-a16d-380a780b14c4\",\"add\":11285,\"del\":2483}]","description":"CommandInformationCommandInformationshow running-configRunning configurationshow vlanVLANs in VLAN databaseshow interfaces statusAll interface statusshow mac address-tableMAC address tableshow interfaces Gi0/1Detail of specified interfaceshow etherchannel summaryPort-channel statusshow vlanVLANs in VLAN databaseshow ?If you have no idea"}