三層交換機(jī)配置的實(shí)例教程
遇到過(guò)三層交換機(jī)配置嗎?對(duì)詳細(xì)的命令熟悉了嗎?你的三層交換機(jī)是不是經(jīng)常讓你機(jī)器不好使,接下來(lái)是小編為大家收集的三層交換機(jī)配置的實(shí)例教程,希望能幫到大家。
三層交換機(jī)配置的實(shí)例教程
三層交換機(jī)配置:
Enable //進(jìn)入私有模式
Configure terminal //進(jìn)入全局模式
service password-encryption //對(duì)密碼進(jìn)行加密
hostname Catalyst 3550-12T1 //給三層交換機(jī)定義名稱(chēng)
enable password 123456. //enable密碼
Enable secret 654321 //enable的加密密碼(應(yīng)該是亂碼而不是654321這樣)
Ip subnet-zero //允許使用全0子網(wǎng)(默認(rèn)都是打開(kāi)的)
Ip name-server 172.16.8.1 172.16.8.2 //三層交換機(jī)名字Catalyst 3550-12T1對(duì)應(yīng)的IP地址是172.16.8.1
Service dhcp //提供DHCP服務(wù)
ip routing //啟用三層交換機(jī)上的路由模塊
Exit
三層交換機(jī)配置:
Vtp mode server //定義VTP工作模式為sever模式
Vtp domain centervtp //定義VTP域的名稱(chēng)為centervtp
Vlan 2 name vlan2 //定義vlan并給vlan取名(如果不取名的話(huà),vlan2的名字應(yīng)該是vlan002)
Vlan 3 name vlan3
Vlan 4 name vlan4
Vlan 5 name vlan5
Vlan 6 name vlan6
Vlan 7 name vlan7
Vlan 8 name vlan8
Vlan 9 name vlan9
Exit
三層交換機(jī)配置:
interface Port-channel 1 //進(jìn)入虛擬的以太通道組1
switchport trunk encapsulation dot1q //給這個(gè)接口的trunk封裝為802.1Q的幀格式
switchport mode trunk //定義這個(gè)接口的工作模式為trunk
switchport trunk allowed vlan all //在這個(gè)trunk上允許所有的vlan通過(guò)
Interface gigabitethernet 0/1 //進(jìn)入模塊0上的吉比特以太口1
switchport trunk encapsulation dotlq //給這個(gè)接口的trunk封裝為802.1Q的幀格式
switchport mode trunk //定義這個(gè)接口的工作模式為trunk
switchport trunk allowed vlan all //在這個(gè)trunk上允許所有的vlan通過(guò)
channel-group 1 mode on //把這個(gè)接口放到快速以太通道組1中
Interface gigabitethernet 0/2 //同上
switchport trunk encapsulation dotlq
switchport mode trunk
switchport trunk allowed vlan all
channel-group 1 mode on
三層交換機(jī)配置:
port-channel load-balance src-dst-ip //定義快速以太通道組的負(fù)載均衡方式(依*源和目的IP的方式)
interface gigabitethernet 0/3 //進(jìn)入模塊0上的吉比特以太口3
switchport trunk encapsulation dotlq //給trunk封裝為802.1Q
switchport mode trunk //定義這個(gè)接口的工作模式為trunk
switchport trunk allowed vlan all //允許所有vlan信息通過(guò)
interface gigabitethernet 0/4 //同上
switchport trunk encapsulation dotlq
switchport mode trunk
switchport trunk allowed vlan all
interface gigbitethernet 0/5 //同上
switchport trunk encapsulation dotlq
switchport mode trunk
switchport trunk allowed vlan all
interface gigbitethernet 0/6 //同上
switchport trunk encapsulation dotlq
switchport mode trunk
switchprot trunk allowed vlan all
三層交換機(jī)配置:
interface gigbitethernet 0/7 //進(jìn)入模塊0上的吉比特以太口7
Switchport mode access //定義這個(gè)接口的工作模式為訪(fǎng)問(wèn)模式
switchport access vlan 9 //定義這個(gè)接口可以訪(fǎng)問(wèn)哪個(gè)vlan(實(shí)際就是分配這個(gè)接口到vlan)
no shutdown
spanning-tree vlan 6-9 cost 1000 //在生成樹(shù)中,vlan6-9的開(kāi)銷(xiāo)定義為10000
interface range gigabitethernet 0/8 – 10 //進(jìn)入模塊0上的吉比特以太口8,9,10
switchport mode access //定義這些接口的工作模式為訪(fǎng)問(wèn)模式
switchport access vlan 8 //把這些接口都分配到vlan8中
no shutdown
三層交換機(jī)配置:
spanning-tree portfast //在這些接口上使用portfast(使用portfast以后,在生成樹(shù)的時(shí)候不參加運(yùn)算,直接成為轉(zhuǎn)發(fā)狀態(tài))
interface gigabitethernet 0/11 //進(jìn)入模塊0上的吉比特以太口11
switchport trunk encapsulation dotlq //給這個(gè)接口封裝為802.1Q
switchport mode trunk //定義這個(gè)接口的工作模式為trunk
switchport trunk allowed vlan all //允許所有vlan信息通過(guò)
interface gigabitethernet 0/12 //同上
switchport trunk encapsulation dotlq
switchport mode trunk
switchport trunk allowed vlan all
interface vlan 1 //進(jìn)入vlan1的邏輯接口(不是物理接口,用來(lái)給vlan做路由用)
ip address 172.16.1.7 255.255.255.0 //配置IP地址和子網(wǎng)掩碼
no shutdown
三層交換機(jī)配置:
standby 1 ip 172.16.1.9 //開(kāi)啟了冗余熱備份(HSRP),冗余熱備份組1,虛擬路由器的IP地址為172.16.1.9
standby 1 priority 110 preempt //定義這個(gè)三層交換機(jī)在冗余熱備份組1中的優(yōu)先級(jí)為110,preempt是用來(lái)開(kāi)啟搶占模式
interface vlan 2 //同上
ip address 172.16.2.252 255.255.255.0
no shutdown
standby 2 ip 172.16.2.254
standby 2 priority 110 preempt
ip access-group 101 in //在入方向上使用擴(kuò)展的訪(fǎng)問(wèn)控制列表101
interface vlan 3 //同上
ip address 172.16.3.252 255.255.255.0
no shutdown
三層交換機(jī)配置:
standby 3 ip 172.16.3.254
standby 3 priority 110 preempt
ip access-group 101 in
interface vlan 4 //同上
ip address 172.16.4.252 255.255.255.0
no shutdown
standby 4 ip 172.16.4.254
standby 4 priority 110 preempt
ip access-group 101 in
interface vlan 5
ip address 172.16.5.252 255.255.255.0
no shutdown
standby 5 ip 172.16.5.254
standby 5 priority 110 preempt
ip access-group 101 in
interface vlan 6
ip address 172.16.6.252 255.255.255.0
no shutdown
三層交換機(jī)配置:
standby 6 ip 172.16.6.254
standby 6 priority 100 preempt
interface vlan 7
ip address 172.16.7.252 255.255.255.0
no shutdown
standby 7 ip 172.16.7.254
standby 7 priority 100 preempt
interface vlan 8
ip address 172.16.8.252 255.255.255.0
no shutdown
standby 8 ip 172.16.8.254
standby 8 priority 100 preempt
interface vlan 9
ip address 172.16.9.252 255.255.255.0
no shutdown
三層交換機(jī)配置:
standby 9 ip 172.16.9.254
standby 9 priority 100 preempt
access-list 101 deny ip any 172.16.7.0 0.0.0.255 //擴(kuò)展的訪(fǎng)問(wèn)控制列表101
access-list 101 permit ip any any
Interface vlan 1 //進(jìn)入vlan1這個(gè)邏輯接口
Ip helper-address 172.16.8.1 //可以轉(zhuǎn)發(fā)廣播(helper-address的作用就是把廣播轉(zhuǎn)化為單播,然后發(fā)向172.16.8.1)
Interface vlan 2
Ip helper-address 172.16.8.1
Interface vlan 3
ip helper-address 172.16.8.1
interface vlan 4
ip helper-address 172.16.8.1
interface vlan 5
ip helper-address 172.16.8.1
interface vlan 6
ip helper-address 172.16.8.1
interface vlan 7
ip helper-address 172.16.8.1
interface vlan 9
ip helper-address 172.16.8.1
router rip //啟用路由協(xié)議RIP
version 2 //使用的是RIPv2,如果沒(méi)有這句,則是使用RIPv1
network 172.16.0.0 //宣告直連的網(wǎng)段
exit
三層交換機(jī)配置:
ip route 0.0.0.0 0.0.0.0 172.16.9.250 //缺省路由,所有在路由表中沒(méi)有辦法匹配的數(shù)據(jù)包,都發(fā)向下一跳地址為172.16.9.250這個(gè)路由器
line con 0
line aux 0
line vty 0 15 //telnet線(xiàn)路(路由器只有5個(gè),是0-4)
password 12345678 //login密碼
login
end
copy running-config startup-config 保存配置
看了“三層交換機(jī)配置的實(shí)例教程”還想看:
4.思科模擬器配置三層交換機(jī)局域網(wǎng)的詳解