交換機(jī)
1.交換機(jī)的工作模式
Switch>enable(用戶模式)
Switch#configure terminal(特權(quán)模式)
Switch(config)#interface fastEthernet 0/1(全局配置模式)
Switch(config-if)#ip address 192.168.1.1 255.255.255.0(接口模式)
no shutdown(開啟接口)
exit返回上一模式
end直接退到特權(quán)模式
2.常用命令
特權(quán)模式下
show running-config(查看配置信息)
show version(查看IOS版本信息)
show mac-address-table(查看MAC地址表)
show interface fastethernet 0/1(查看接口信息雙工和速率)
write(保存交換機(jī)配置)
reload(恢復(fù)設(shè)備出廠默認(rèn)值)
全局模式下
hostname default(修改主機(jī)名)
enable password 123456(配置enable明文口令)
enable secret 123456(配置enable加密口令)
no ip domain-lookup(禁用DNS查詢)
接口模式下
ip address ip地址 子網(wǎng)掩碼(配置靜態(tài)ip)
duplex [full|half|auto](全雙工、半雙工、自動(dòng))
speed[10|100|1000|auto](通信速率)
vlan的配置
vlan 10(創(chuàng)建vlan)
name aaa(進(jìn)入vlan后給vlan命名)
interface vlan 10(進(jìn)入vlan10)
ip address 192.168.1.10 255.255.255.0
no shutdown
no vlan 10(刪除vlan)
interface range f0/1 – 10
switchport access vlan 10(將1-10接口劃入vlan10)
默認(rèn)網(wǎng)關(guān)配置
ip default-gateway 192.168.1.1
虛擬端口配置(telnet)
line vty 0 4
password 123456
login
路由器
查看路由表
show ip route
路由接口ip配置
intface serial0/1
ip address 192.168.1.1 255.255.255.0
clock rate 64000(設(shè)置時(shí)鐘)
no shutdown
默認(rèn)路由
ip route 0.0.0.0 0.0.0.0 下一跳
靜態(tài)路由配置
ip route 目標(biāo)網(wǎng)絡(luò)ID 子網(wǎng)掩碼 下一跳ip或設(shè)備出口的接口
RIP配置
route rip
network 192.168.10.0(路由中的網(wǎng)段)
network 192.168.20.0
version 2
no auto-summary
ospf配置
route ospf 10(設(shè)置進(jìn)程號(hào))
network 192.168.10.0 0.0.0.255 area 0(area設(shè)置區(qū)域號(hào))
network 192.168.20.0 0.0.0.255 area 0
nat配置
ip nat inside source static 192.168.1.1 172.16.1.1(靜態(tài)ip轉(zhuǎn)換)
int f0/0
ip nat inside
int f0/1
ip nat outside
出口段連接的設(shè)備做ip route就好了
DHCP配置
ip route pool aaa(定義地址池)
network 192.168.1.0 255.255.255.0(動(dòng)態(tài)分配)
default-router 192.168.1.1(動(dòng)態(tài)分配網(wǎng)關(guān))
dns-server 8.8.8.8(動(dòng)態(tài)分配dns服務(wù)器地址)
exit
ip dhcp excluded-address 192.168.1.100 192.168.1.110(排除的ip地址)
ip helper-address 192.168.1.250(DHCP中繼地址---向服務(wù)器請(qǐng)求分配DHCP地址)
ACL配置(acl編號(hào)取值范圍(100-199))
access-list 101 deny host 192.168.1.10(拒絕ip為192.168.1.10的主機(jī)訪問路由出口的主機(jī))
access-list 101 deny any(允許其他的流量訪問)
進(jìn)入接口后
ip access-group 101 in(將ACL應(yīng)用與接口,生效ACL配置)
擴(kuò)展ACL配置(配置完后記得用access-group生效配置)
access-list 101 permit tcp 192.168.10.0 0.0.0.255 host 192.168.20.5 eq www|80(允許192.168.1.10的網(wǎng)段走tcp協(xié)議訪問192.168.20.5的主機(jī)的萬維網(wǎng)服務(wù))
補(bǔ)充acl編號(hào)取值范圍(100-199)
access-list 101 permit any any(允許其他網(wǎng)段訪問)
show access-list 101(查看ACL信息)
三層交換機(jī)配置
開啟路由功能
ip routing
配置trunk并封裝
switchport trunk encapsulation dot1q
switchport mode trunk
no switchport (進(jìn)入真實(shí)接口)
。
。。
。。。
。。。。
。。。。。
三次在我感覺就是多了路由功能的交換機(jī),配置看上面的就好了
單臂路由實(shí)例
[圖片上傳失敗...(image-e00753-1581937956576)]
SW1配置
Switch>enable
Switch#config terminal
Switch(config)#hostname SW1
SW1(config)#vlan2
SW1(config-vlan)#exit
SW1(config)vlan 3
SW1(config-vlan)exit
SW1(config)#interface fastEthernet 1/1
SW1(config-if)#switchport mode access(配置接口為access口,科普除trunk模式外還有access、hybrid)
SW1(config-if)#switchport access vlan 2
SW1(config-if)#exit
SW1(config)#interface fastEthernet 2/1
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 3
SW1(config-if)#exit
SW1(config)#interface fastEthernet 0/1
SW1(config-if)#switchport mode trunk
SW1(config-if)#switchport trunk allowed vlan 2,3(配置turnk口允許vlan2 和vlan3通過,除了vlan2和vlan3,其他所有的vlan默認(rèn)拒絕所有,這里實(shí)驗(yàn)可加可不加)
R1配置
Switch>enable
Swtich#config terminal
Switch(config)#hostname R1
R1(config)#interface fastEthernet 0/0
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#interface fastEthernet0/0.1
R1(config-subif)#encapsulation dot1Q 2
R1(config-subif)#ip address 192.168.2.1 255.255.255.0
R1(config-subif)#exit
R1(config)#interface fastEthernet 0/0.2
R1(config-subif)#encapsulation dot1Q 3
R1(config-subif)#ip address 192.168.3.1 255.255.255.0
關(guān)于trunk、access、hybrid的理解
具有access性質(zhì)的端口只能屬于一個(gè)vlan,且端口不打tag
具有trunk性質(zhì)的端口可以屬于多個(gè)vlan,且端口都是打tag的
具有hubrid性質(zhì)的端口可以屬于多個(gè)vlan,是否打開tag由用戶而定
tag的理解就想貼了同樣標(biāo)簽的東西他們是可以互相通信的,比如小米手機(jī)用MIUI系統(tǒng),而蘋果手機(jī)用IOS系統(tǒng)