華為三層交換機配置命令
你的三層交換機是不是經常讓你機器不好使,看看下面的三層交換機配置文章,一切問題都能解決。yjbys詳細介紹例項講解:全面的三層交換機配置比較全面的三層交換機配置例項,帶命令解釋喲!快來get吧!
三層交換機配置:
Enable //進入私有模式
Configure terminal //進入全域性模式
service password-encryption //對密碼進行加密
hostname Catalyst 3550-12T1 //給三層交換機定義名稱
enable password 123456. //enable密碼
Enable secret 654321 //enable的加密密碼(應該是亂碼而不是654321這樣)
Ip subnet-zero //允許使用全0子網(預設都是開啟的)
Ip name-server //三層交換機名字Catalyst 3550-12T1對應的IP地址是
Service dhcp //提供DHCP服務
ip routing //啟用三層交換機上的路由模組
Exit
三層交換機配置:
Vtp mode server //定義VTP工作模式為sever模式
Vtp domain centervtp //定義VTP域的名稱為centervtp
Vlan 2 name vlan2 //定義vlan並給vlan取名(如果不取名的話,vlan2的名字應該是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
三層交換機配置:
interface Port-channel 1 //進入虛擬的`以太通道組1
switchport trunk encapsulation dot1q //給這個介面的trunk封裝為802.1Q的幀格式
switchport mode trunk //定義這個介面的工作模式為trunk
switchport trunk allowed vlan all //在這個trunk上允許所有的vlan通過
Interface gigabitethernet 0/1 //進入模組0上的吉位元以太口1
switchport trunk encapsulation dotlq //給這個介面的trunk封裝為802.1Q的幀格式
switchport mode trunk //定義這個介面的工作模式為trunk
switchport trunk allowed vlan all //在這個trunk上允許所有的vlan通過
channel-group 1 mode on //把這個介面放到快速以太通道組1中
Interface gigabitethernet 0/2 //同上
switchport trunk encapsulation dotlq
switchport mode trunk
switchport trunk allowed vlan all
channel-group 1 mode on
三層交換機配置:
port-channel load-balance src-dst-ip //定義快速以太通道組的負載均衡方式(依*源和目的IP的方式)
interface gigabitethernet 0/3 //進入模組0上的吉位元以太口3
switchport trunk encapsulation dotlq //給trunk封裝為802.1Q
switchport mode trunk //定義這個介面的工作模式為trunk
switchport trunk allowed vlan all //允許所有vlan資訊通過
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
三層交換機配置:
interface gigbitethernet 0/7 //進入模組0上的吉位元以太口7
Switchport mode access //定義這個介面的工作模式為訪問模式
switchport access vlan 9 //定義這個介面可以訪問哪個vlan(實際就是分配這個介面到vlan)
no shutdown
spanning-tree vlan 6-9 cost 1000 //在生成樹中,vlan6-9的開銷定義為10000
interface range gigabitethernet 0/8 – 10 //進入模組0上的吉位元以太口8,9,10
switchport mode access //定義這些介面的工作模式為訪問模式
switchport access vlan 8 //把這些介面都分配到vlan8中
no shutdown
三層交換機配置:
spanning-tree portfast //在這些介面上使用portfast(使用portfast以後,在生成樹的時候不參加運算,直接成為轉發狀態)
interface gigabitethernet 0/11 //進入模組0上的吉位元以太口11
switchport trunk encapsulation dotlq //給這個介面封裝為802.1Q
switchport mode trunk //定義這個介面的工作模式為trunk
switchport trunk allowed vlan all //允許所有vlan資訊通過
interface gigabitethernet 0/12 //同上
switchport trunk encapsulation dotlq
switchport mode trunk
switchport trunk allowed vlan all
interface vlan 1 //進入vlan1的邏輯介面(不是物理介面,用來給vlan做路由用)
ip address //配置IP地址和子網掩碼
no shutdown
三層交換機配置:
standby 1 ip //開啟了冗餘熱備份(HSRP),冗餘熱備份組1,虛擬路由器的IP地址為
standby 1 priority 110 preempt //定義這個三層交換機在冗餘熱備份組1中的優先順序為110,preempt是用來開啟搶佔模式
interface vlan 2 //同上
ip address
no shutdown
standby 2 ip
standby 2 priority 110 preempt
ip access-group 101 in //在入方向上使用擴充套件的訪問控制列表101
interface vlan 3 //同上
ip address
no shutdown
三層交換機配置:
standby 3 ip
standby 3 priority 110 preempt
ip access-group 101 in
interface vlan 4 //同上
ip address
no shutdown
standby 4 ip
standby 4 priority 110 preempt
ip access-group 101 in
interface vlan 5
ip address
no shutdown
standby 5 ip
standby 5 priority 110 preempt
ip access-group 101 in
interface vlan 6
ip address
no shutdown
三層交換機配置:
standby 6 ip
standby 6 priority 100 preempt
interface vlan 7
ip address
no shutdown
standby 7 ip
standby 7 priority 100 preempt
interface vlan 8
ip address
no shutdown
standby 8 ip
standby 8 priority 100 preempt
interface vlan 9
ip address
no shutdown
三層交換機配置:
standby 9 ip
standby 9 priority 100 preempt
access-list 101 deny ip any //擴充套件的訪問控制列表101
access-list 101 permit ip any any
Interface vlan 1 //進入vlan1這個邏輯介面
Ip helper-address //可以轉發廣播(helper-address的作用就是把廣播轉化為單播,然後發向)
Interface vlan 2
Ip helper-address
Interface vlan 3
ip helper-address
interface vlan 4
ip helper-address
interface vlan 5
ip helper-address
interface vlan 6
ip helper-address
interface vlan 7
ip helper-address
interface vlan 9
ip helper-address
router rip //啟用路由協議RIP
version 2 //使用的是RIPv2,如果沒有這句,則是使用RIPv1
network //宣告直連的網段
exit
三層交換機配置:
ip route //預設路由,所有在路由表中沒有辦法匹配的資料包,都發向下一跳地址為這個路由器
line con 0
line aux 0
line vty 0 15 //telnet線路(路由器只有5個,是0-4)
password 12345678 //login密碼
login
end
copy running-config startup-config 儲存配置