思科交換機基本配置

Switch(config-if)#

Vlan設置範圍:1---4094

在全局模式下配置vlan

Switch#conft

Switch(config)#vlan10

Switch(config-vlan)#namevlan10

Switch(config-vlan)#vlan20

Switch(config-vlan)#namevlan20

Vlan名稱可以自行定義

Switch#showvlan 查看vlan配置信息

vlan10配置192.168.10.1/24的ip地址

Switch#conft

Switch(config)#vlan10

Switch(config-vlan)#namevlan10

Switch(config-vlan)#exit

Switch(config)#interfacevlan 10

Switch(config-if)#ipaddress 192.168.10.1 255.255.255.0

Switch(config-if)#end

Switch#copyrunning-config startup-config

配置ip地址的命令格式: ipaddress {ip-address} {netmask}

測試常用端口類型 Access/ trunk

將此端口設置為vlan10的access口

Switch(config-if)#switchportmode access

Switch(config-if)#switchportaccess vlan 10

Switch(config-if)#

將此端口設置為vlan10的trunk口

Switch(config-if)#switchporttrunk encapsulation dot1q

Switch(config-if)#switchportmode trunk

Switch(config-if)#switchporttrunk allowed vlan 10

當一個端口允許多個vlan通過時,trunk allowed vlan中要添加各條vlan信息

Switch(config-if)#switchporttrunk encapsulation dot1q

Switch(config-if)#switchportmode trunk

Switch(config-if)#switchport trunk allowed vlan all

Switch(config-if)#switchporttrunk allowed vlan 10,50,60

Switch(config-if)#switchporttrunk allowed vlan add 20 (remove刪除)

Switch(config-if)#switchporttrunk allowed vlan add 30

Switch(config-if)#switchporttrunk allowed vlan add 40

Switch(config-if)#switchporttrunk native vlan 1

Switch(config-if)#noshutdown

Switch(config-if)#end

Switch#copyrunning-config startup-config

此端口為vlan10 vlan20 vlan30 vlan40的trunk口,defaultvlan 1經過此端口時不會帶上標籤。

當一個端口允許多個vlan通過時,trunk allowed vlan中要添加各條vlan信息

Switch(config-if)#switchporttrunk encapsulation dot1q

Switch(config-if)#switchportmode trunk

Switch(config-if)#switchport trunk allowed vlan all

Switch(config-if)#switchporttrunk allowed vlan 10,50,60

Switch(config-if)#switchporttrunk allowed vlan add 20 (remove刪除)

Switch(config-if)#switchporttrunk allowed vlan add 30

Switch(config-if)#switchporttrunk allowed vlan add 40

Switch(config-if)#switchporttrunk native vlan 1

Switch(config-if)#noshutdown

Switch(config-if)#end

Switch#copyrunning-config startup-config

此端口為vlan10 vlan20 vlan30 vlan40的trunk口,defaultvlan 1經過此端口時不會帶上標籤。

光端口配置

Switch(config)#interfacegigabitEthernet 0/25

Switch(config-if)#switchport mode access

Switch(config-if)#switchportaccess vlan 10

Switch(config-if)#noshutdown

Switch(config-if)#end

Switch#copyrunning-config startup-config

注意:

由於思科的交換機只自動識別自己品牌的光模塊,所以如果用其他品牌的光模塊,需在配置模式下輸入一下兩條命令,開啟兼容性。

serviceunsupported-transceiver

noerrdisable detect cause gbic-invalid

命令輸入完成後保存設置重啟設備 。

配置一個dhcp給vlan10內的主機分配地址

Switch(config)#servicedhcp

Switch(config)#ipdhcp pool vlan10

Switch(dhcp-config)#network192.168.10.0 255.255.255.0

Switch(dhcp-config)#default-router192.168.10.1

Switch(dhcp-config)#dns-server192.168.10.2

Switch(dhcp-config)#lease3 20 20 (天/小時/分鐘)(缺省為1天)

Switch(dhcp-config)#exit

Switch(config)#ip dhcp excluded-address 192.168.10.1192.168.10.19

Switch(config)#

ipdhcp excluded-address 排除某些地址,禁止被動態分配

DHCP設置是針對全局的,不是定義在某個接口上的。

DHCP調試命令

Switch(config)#noservice dhcp 關閉dhcp服務

Switch#showip dhcp binding 查看dhcp分配情況

思科作DHCP server給AP分地址

在server中設置Option43、Option60字段信息。

Switch(config)#ipdhcp pool vlan20

Switch(dhcp-config)#network192.168.1.0 255.255.255.0

Switch(dhcp-config)#default-router192.168.1.1

Switch(dhcp-config)#option43 hex 0106 0104 c0a8 01e4

Switch(dhcp-config)#option60 hex xxxx xxxx xxxx (AC回的offer包中的信息)

Switch(dhcp-config)#lease 1

Switch(dhcp-config)#end

Switch#copyrunning-config startup-config

DHCPrelay功能可以匯聚處於不同廣播域的客戶端的DHCP請求,轉發給DHCP服務器,併發送DHCP服務器的響應給各個客戶端,也就是起到了DHCP報文在各個網段的轉發功能。Cisco的設備需要啟用ip helper-address命令,來實現此功能。•配置了ip helper-address命令之後的交換機在中繼DHCP請求時的工作過程如下:

(1)DHCP客戶端發送請求,由於沒有IP地址,所以自己的源IP地址為0.0.0.0,而且也不知道目的DHCP服務器的地址,所以廣播255.255.255.255。該數據報文中還包括源mac地址和目的mac地址(全F)。

(2)當交換機接收到該數據包的時候,它就用自己的接口地址來取代源地址0.0.0.0,並且用ip helper-address命令置頂的地址來取代目的地址255.255.255.255。

(3)當DHCP服務器接收到交換機轉發過來的DHCP請求包時,它會做出響應,並且由交換機把數據包轉發回客戶端。

DHCPrelay 配置

Switch(config)#vlan100

Switch(config-vlan)#namevlan100

Switch(config-vlan)#intvlan 100

Switch(config-if)#ip helper-address 192.168.1.228

Switch(config-if)#exit

Switch(config)#servicedhcp

Switch(config)#ipdhcp relay information trust-all

Switch(config)#end

Switch#copyrunning-config startup-config

DHCPrelay功能測試實例:

AClan端口開啟dhcpserver

dhcpserver1:192.168.20.10---192.168.20.100/24的地址,網關為192.168.20.1。

dhcpserver2:192.168.30.10---192.168.30.100/24的地址,網關為192.168.30.1。

AClan端口地址為192.168.1.228•正確配置交換機和AC使AP獲得相應地址並上線。

思科交換機基本配置

Cisco3560G配置

interfaceGigabitEthernet0/1 interface Vlan10

switchportaccess vlan 10 ipaddress 192.168.1.1 255.255.255.0

switchportmode access

!

interfaceGigabitEthernet0/2 interface Vlan20

switchport access vlan 20 ip address 192.168.20.1255.255.255.0

switchport mode access ip helper-address192.168.1.228

!

interfaceGigabitEthernet0/3 interface Vlan30

switchport access vlan 30 ip address 192.168.30.1255.255.255.0

switchport mode access ip helper-address192.168.1.228

iprouting service dhcp

ip dhcp relay information trust-all

AC配置

瘦AP端口地址:192.168.1.228 255.255.255.0

瘦AP端口DHCP:

dhcpserver1:192.168.20.10---192.168.20.100/24的地址,網關為192.168.20.1。

dhcpserver2:192.168.30.10---192.168.30.100/24的地址,網關為192.168.30.1。

靜態路由:

目的地址 0.0.0.0

子網掩碼 0.0.0.0

下一跳 192.168.1.1

Switch(config)#iprouting (全局路由)思科默認不開啟

Switch(config)#iproute 192.168.2.0 255.255.255.0 192.168.1.1 (靜態路由格式:目的地址 子網掩碼 下一跳)

靜態路由測試實例

AP通過dhcp方式上線,集中轉發正常廣播SSID•AC開啟2個虛接口,STA連接vif1,Vif1屬於vlan1地址192.168.10.1/24,vif2屬於vlan2地址192.168.20.1/24

3560G1端口與AC的vif2相連,地址為192.168.20.2/24

3560G2端口與PC相連,地址為192.168.30.1/24

PC的地址為192.168.30.1/24網關為192.168.30.1

測試要求:STA正常獲得地址並且與PC通信。

Cisco3560G配置

interfaceVlan20

ipaddress 192.168.20.2 255.255.255.0

interfaceVlan30

ipaddress 192.168.30.1 255.255.255.0

iproute 192.168.10.0 255.255.255.0 192.168.20.1

iprouting

interfaceGigabitEthernet0/1

switchport access vlan 20

switchport mode access

interfaceGigabitEthernet0/2

switchport access vlan 30

switchport mode access

AC開啟2個虛接口vif1、vif2,vif1開啟dhcpserver功能,給STA分配地址,同時將vif1的地址設置為網關。

同時配置靜態路由

目的地址 192.168.30.0

子網掩碼 255.255.255.0

下一跳: 192.168.20.2

思科交換機基本配置

在三層交換機上劃分三個VLAN,VLAN10 VLAN20 VLAN30,其管理地址分別為192.168.10.1,192.168.20.1,192.168.1.226,瘦AP通過DHCP的方式獲得地址,解析到交換機的地址。

AC配置:

AP通過cisco獲得地址,通過option43字段信息找到AC並關聯上線。

AC設置缺省路由,下一跳指向與lan口相連的cisco端口地址。

AC開啟vif與radius服務器能夠正常通信。

瘦AP模板

AP下發相同的模板,STA正常關聯後經過802.1x認證。

關聯成功後,查看無線終端列表,將未關聯的AP信號加強,使STA漫遊至與這臺AP關聯。

STA開啟抓包,在發生切換時應該能抓到reassociation的重關聯報文。


分享到:


相關文章: