基礎實驗之access/trunk/valn/vlanif/靜態路由
實驗要求
1,PC1,PC2,PC3,PC4分別屬於VLAN10,20,30,40
2,PC1,PC2,PC3,PC4互通
步驟1:PC1,2,3,4分別配置IP,並在SW6,SW7分別配置閘道器,並都可以PING通自己的閘道器
連線終端一般情況多用access,連線網路裝置多用trunk,所以SW2,3,4,5的g0/0/1口為access,g0/0/2口為trunk.
SW2的配置SW3,4,5類似
#
vlan batch 10 20 30 40//因為要求PC互通所以每一個需要經過的交換機都需要建立所有PC的對應VALN
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 10//每個交換機的埠加入相應VLAN
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20 30 40//要求PC互通所以需要放行相應VLAN
SW6配置,SW7類似
#
interface Vlanif10
ip address 10.1.1.1 255.255.255.0
#
interface Vlanif20
ip address 20.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20 30
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20 30 40
#
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass all//放行所有VLAN
2,閘道器可以通訊後,就要配置SW8,寫靜態路由(因為PC所在網段不同,所以需要靜態路由)
因為需要跨網段傳輸資料,所已SW6,SW7的上行介面也需要介面地址,於是分別建立VLAN2,VLAN3
SW8也需要建立SW6和SW7的VLAN2,VLAN3並且對應VLANIF地址要和SW6,SW7VLANIF在相同網段
SW6配置
#
vlan batch 2
#
interface Vlanif2
ip address 2.2.2.6 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 2.2.2.8//預設路由
SW7配置
#
vlan batch 3
#
interface Vlanif3
ip address 3.3.3.7 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 3.3.3.8
SW8配置
#
vlan batch 2 to 3 10 20 30 40
#
interface Vlanif2
ip address 2.2.2.8 255.255.255.0
#
interface Vlanif3
ip address 3.3.3.8 255.255.255.0
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass all
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass all
#
ip route-static 10.1.1.0 255.255.255.0 2.2.2.6//明細路由
ip route-static 20.1.1.0 255.255.255.0 2.2.2.6
ip route-static 30.1.1.0 255.255.255.0 3.3.3.7
ip route-static 40.1.1.0 255.255.255.0 3.3.3.7
驗證:PC1可以ping通PC2,PC3,PC4
==========================
作者:暖巷尋故人