跳轉到內容

CCNA 認證/高階交換主題

來自華夏公益教科書,開放書籍,開放世界

高階交換主題

[編輯 | 編輯原始碼]

沒有 DHCP 的 IP 源守衛 當啟用 DHCP 偵聽時,交換機維護一個 DHCP 地址資料庫,這些地址分配給連線到每個訪問埠的主機。IP 源守衛在訪問介面上接收到資料包時引用該資料庫,並將源地址與資料庫中列出的分配地址進行比較。如果源地址與“允許”的地址不同,則假定資料包是偽造的,並將其丟棄。假設子網不可用或未使用 DHCP,則可以手動配置每個訪問埠的靜態 IP 繫結以達到相同的效果。

配置

sw1(config)#ip dhcp snooping

sw1(config)#ip dhcp snooping vlan 146

sw1(config)#interface FastEthernet0/13

switchport access vlan 146

switchport trunk encapsulation dot1q

switchport mode access

ip verify source

sw1(config)#interface FastEthernet0/16

switchport access vlan 146

switchport mode access

ip verify source

sw1(config)#ip source binding 000D.29C0.F180 vlan 146 155.1.0.2 interface Fa0/13

sw1(config)#ip source binding 000D.29E3.AB00 vlan 146 155.1.0.3 interface Fa0/16

sw1(config)#do sh ip source binding

MacAddress IpAddress Lease(sec) Type VLAN Interface


--------------- ---------- ------------- ---- --------------------

0:0D:29:C0:F1:80 155.1.0.2 無限 靜態 146 FastEthernet0/13

00:0D:29:E3:AB:00 155.1.0.3 無限 靜態 146 FastEthernet0/16

繫結總數:2

sw1(config)#do sh ip verify source

Interface Filter-type Filter-mode IP-address Mac-address Vlan


----------- ----------- --------------- ----------------- ----------

Fa0/13 ip active 155.1.0.2 146

Fa0/16 ip active 155.1.0.3 146

sw1(config)#

如果你沒有在 sw1 上啟用 dhcp 偵聽,它將在任何 Filter-mode 列表中顯示以下內容:inactive-no-snooping-vlan

                                                   entry.                                                                                                                                    

sw1(config)#no ip dhcp snooping vlan 146

sw1(config)#do sh ip verify source

Interface Filter-type Filter-mode IP-address Mac-address Vlan


----------- ----------- --------------- ----------------- ----------

Fa0/13 ip inactive-no-snooping-vlan

Fa0/16 ip inactive-no-snooping-vlan 將 sw2 的 IP 地址更改為 155.1.0.22,現在嘗試 ping 155.1.0.3(sw3 的 IP 地址),以下錯誤訊息將在 sw1(3560) 中生成。

sw1(config)#

02:30:26: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0. f180/155.1.0.22/000d.29e3.ab00/155.1.0.3/02:30:25 UTC Mon Mar 1 1993]) 02:30:26: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(響應),vlan 146。([000d.29c0. f180/155.1.0.22/ffff.ffff.ffff/155.1.0.22/02:30:25 UTC Mon Mar 1 1993]) 02:30:33: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0. f180/155.1.0.22/0000.0000.0000/155.1.0.3/02:30:32 UTC Mon Mar 1 1993]) 02:30:35: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0 f180/155.1.0.22/0000.0000.0000/155.1.0.3/02:30:34 UTC Mon Mar 1 1993]) 02:30:37: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0. f180/155.1.0.22/0000.0000.0000/155.1.0.3/02:30:36 UTC Mon Mar 1 1993]) 02:30:39: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0. f180/155.1.0.22/0000.0000.0000/155.1.0.3/02:30:38 UTC Mon Mar 1 1993]) 02:30:40: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0. f180/155.1.0.22/0000.0000.0000/155.1.0.3/02:30:40 UTC Mon Mar 1 1993]) 02:30:42: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0. f180/155.1.0.22/0000.0000.0000/155.1.0.3/02:30:42 UTC Mon Mar 1 1993]) 02:30:44: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0. f180/155.1.0.22/0000.0000.0000/155.1.0.3/02:30:44 UTC Mon Mar 1 1993]) 02:30:46: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0. f180/155.1.0.22/0000.0000.0000/155.1.0.3/02:30:46 UTC Mon Mar 1 1993]) sw1(config)# 02:39:44: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(請求),vlan 146。([000d.29c0. f180/155.1.0.22/000d.29e3.ab00/155.1.0.3/02:39:43 UTC Mon Mar 1 1993]) 02:39:44: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Fa0/13 上無效的 ARP(響應),vlan 146。([000d.29c0. f180/155.1.0.22/ffff.ffff.ffff/155.1.0.22/02:39:43 UTC Mon Mar 1 1993]) sw1(config)# do sh ip arp inspection 源 MAC 驗證  : 停用 目標 MAC 驗證 : 停用 IP 地址驗證  : 停用

Vlan     Configuration    Operation   ACL Match          Static ACL
----     -------------    ---------   ---------          ---------- 

146 啟用 活動 VLAN ACL 記錄 DHCP 記錄

----     -----------      ------------
 146     Deny             Deny                                                                                                                                                   Vlan      Forwarded        Dropped     DHCP Drops      ACL Drops
----      ---------        -------     ----------      ---------
 146              3             12             12              0     
Vlan   DHCP Permits    ACL Permits   Source MAC Failures
----   ------------    -----------   -------------------
 146              3              0                     0
Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
----   -----------------   ----------------------   ---------------------
Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
----   -----------------   ----------------------   ---------------------
 146                   0                        0                       0

sw1(config)#ip arp inspection vlan 146


在沒有 DHCP 伺服器的 SW1 上啟用 DAI sw1(config)#ip arp inspection vlan 146

sw1(config)#ip arp inspection filter vlan146 vlan 146

sw1(config)#interface FastEthernet0/13

switchport access vlan 146

switchport trunk encapsulation dot1q

switchport mode access

ip arp inspection limit rate 50 burst interval 10

sw1(config)#interface FastEthernet0/16

switchport access vlan 146

switchport mode access

sw1(config)#interface FastEthernet0/19

switchport access vlan 146

switchport mode access

sw1(config)#arp access-list vlan146

permit ip host 155.1.0.2 mac host 000d.29c0.f180

permit ip host 155.1.0.3 mac host 000d.29e3.ab00

在 SW2 上

sw2(config)#interface FastEthernet0/13

no switchport

ip address 155.1.0.2 255.255.255.0

no shutdown

在 SW3 上

sw3(config)#interface FastEthernet0/13

no switchport

ip address 155.1.0.3 255.255.255.0

no shutdown

在 SW4 上

interface FastEthernet0/13

no switchport

ip address 155.1.0.4 255.255.255.0

no shutdown

當你嘗試從 sw4 ping 時,它將在 sw1 中生成 arp 錯誤,但在 sw2 和 sw3 的情況下不會出現問題,因為 IP 地址到 MAC 地址的對映是使用 arp-acl 完成的。

華夏公益教科書