需求:是pc1,pc2,pc3直接可以相互通信,ip分別pc1:192.168.1.2 pc2:192.168.3.2 pc3:192.168.5.2
LSW1配置:
首先划分vlan,vlan中配置ip,把端口划分到vlan中,給端口配置ip,ospf宣告網段,IP段是根據子網划分的,這里划分的是192.168.2.1 255.255.255.252 30位掩碼
[Huawei]dis current-configuration # sysname Huawei # vlan batch 10 # cluster enable ntdp enable ndp enable # drop illegal-mac alarm # diffserv domain default # drop-profile default # aaa authentication-scheme default authorization-scheme default accounting-scheme default domain default domain default_admin local-user admin password simple admin local-user admin service-type http # interface Vlanif1 ip address 192.168.1.1 255.255.255.0 # interface Vlanif10 ip address 192.168.2.1 255.255.255.252 # interface MEth0/0/1 # interface Ethernet0/0/1 port link-type access port default vlan 10 # interface Ethernet0/0/2 port link-type access # interface GigabitEthernet0/0/1 # interface GigabitEthernet0/0/2 # interface NULL0 # ospf 1 area 0.0.0.100 network 192.168.1.0 0.0.0.255 network 192.168.2.0 0.0.0.3 # user-interface con 0 user-interface vty 0 4 # return
學習到的網段
<Huawei>dis ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 10 Routes : 10 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/24 Direct 0 0 D 192.168.1.1 Vlanif1 192.168.1.1/32 Direct 0 0 D 127.0.0.1 Vlanif1 192.168.2.0/30 Direct 0 0 D 192.168.2.1 Vlanif10 192.168.2.1/32 Direct 0 0 D 127.0.0.1 Vlanif10 192.168.2.4/30 OSPF 10 2 D 192.168.2.2 Vlanif10 192.168.3.0/24 OSPF 10 3 D 192.168.2.2 Vlanif10 192.168.4.0/24 OSPF 10 3 D 192.168.2.2 Vlanif10 192.168.5.0/24 OSPF 10 4 D 192.168.2.2 Vlanif10
LSW2配置:
首先划分vlan,vlan中配置ip,把端口划分到vlan中,給端口配置ip,ospf宣告網段,IP段是根據子網划分的,這里划分的是192.168.2.4/5 255.255.255.252 30位掩碼
<Huawei>dis current-configuration # sysname Huawei # vlan batch 10 20 # cluster enable ntdp enable ndp enable # drop illegal-mac alarm # diffserv domain default # drop-profile default # aaa authentication-scheme default authorization-scheme default accounting-scheme default domain default domain default_admin local-user admin password simple admin local-user admin service-type http # interface Vlanif1 # interface Vlanif10 ip address 192.168.2.2 255.255.255.252 # interface Vlanif20 ip address 192.168.2.5 255.255.255.252 # interface MEth0/0/1 # interface Ethernet0/0/1 port link-type access port default vlan 20 # interface Ethernet0/0/2 port link-type access port default vlan 10 # interface GigabitEthernet0/0/1 # interface GigabitEthernet0/0/2 # interface NULL0 # ospf 1 area 0.0.0.100 network 192.168.2.4 0.0.0.3 network 192.168.2.0 0.0.0.255 # user-interface con 0 user-interface vty 0 4 # return
學習到的網段
<Huawei>dis ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 10 Routes : 10 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/24 OSPF 10 2 D 192.168.2.1 Vlanif10 192.168.2.0/30 Direct 0 0 D 192.168.2.2 Vlanif10 192.168.2.2/32 Direct 0 0 D 127.0.0.1 Vlanif10 192.168.2.4/30 Direct 0 0 D 192.168.2.5 Vlanif20 192.168.2.5/32 Direct 0 0 D 127.0.0.1 Vlanif20 192.168.3.0/24 OSPF 10 2 D 192.168.2.6 Vlanif20 192.168.4.0/24 OSPF 10 2 D 192.168.2.6 Vlanif20 192.168.5.0/24 OSPF 10 3 D 192.168.2.6 Vlanif20
CE1配置:
首先划分vlan,vlan中配置ip,把端口划分到vlan中,給端口配置ip,ospf宣告網段,IP段是根據子網划分的,這里划分的是192.168.2.6 255.255.255.252 30位掩碼
[~HUAWEI]dis current-configuration !Software Version V800R013C00SPC560B560 !Last configuration was updated at 2019-04-02 23:57:11+00:00 # sysname HUAWEI # device board 17 board-type CE-MPUB device board 1 board-type CE-LPUE # vlan batch 20 30 40 # aaa # authentication-scheme default # authorization-scheme default # accounting-scheme default # domain default # domain default_admin # interface Vlanif20 ip address 192.168.2.6 255.255.255.252 # interface Vlanif30 ip address 192.168.3.1 255.255.255.0 # interface Vlanif40 ip address 192.168.4.1 255.255.255.0 # interface MEth0/0/0 undo shutdown # interface GE1/0/0 undo shutdown port default vlan 30 # interface GE1/0/1 undo shutdown port default vlan 40 # interface GE1/0/2 undo shutdown port default vlan 20 # interface NULL0 # ospf 1 area 0.0.0.0 network 192.168.4.0 0.0.0.255 area 0.0.0.100 network 192.168.2.4 0.0.0.3 network 192.168.3.0 0.0.0.255 # ssh authorization-type default aaa # user-interface con 0 # vm-manager # return
學習到的網段:
[~HUAWEI]dis ip routing-table Proto: Protocol Pre: Preference Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route ------------------------------------------------------------------------------ Routing Table : _public_ Destinations : 16 Routes : 16 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/24 OSPF 10 3 D 192.168.2.5 Vlanif20 192.168.2.0/30 OSPF 10 2 D 192.168.2.5 Vlanif20 192.168.2.4/30 Direct 0 0 D 192.168.2.6 Vlanif20 192.168.2.6/32 Direct 0 0 D 127.0.0.1 Vlanif20 192.168.2.7/32 Direct 0 0 D 127.0.0.1 Vlanif20 192.168.3.0/24 Direct 0 0 D 192.168.3.1 Vlanif30 192.168.3.1/32 Direct 0 0 D 127.0.0.1 Vlanif30 192.168.3.255/32 Direct 0 0 D 127.0.0.1 Vlanif30 192.168.4.0/24 Direct 0 0 D 192.168.4.1 Vlanif40 192.168.4.1/32 Direct 0 0 D 127.0.0.1 Vlanif40 192.168.4.255/32 Direct 0 0 D 127.0.0.1 Vlanif40 192.168.5.0/24 OSPF 10 2 D 192.168.4.2 Vlanif40 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
CE2配置:
首先划分vlan,vlan中配置ip,把端口划分到vlan中,給端口配置ip,ospf宣告網段
[~HUAWEI-GE1/0/1]dis current-configuration !Software Version V800R013C00SPC560B560 !Last configuration was updated at 2019-04-02 23:52:32+00:00 # sysname HUAWEI # device board 17 board-type CE-MPUB device board 1 board-type CE-LPUE # vlan batch 40 50 # aaa # authentication-scheme default # authorization-scheme default # accounting-scheme default # domain default # domain default_admin # interface Vlanif40 ip address 192.168.4.2 255.255.255.0 # interface Vlanif50 ip address 192.168.5.1 255.255.255.0 # interface MEth0/0/0 undo shutdown # interface GE1/0/0 undo shutdown port default vlan 50 # interface GE1/0/1 undo shutdown port default vlan 40 # interface NULL0 # ospf 1 area 0.0.0.0 network 192.168.4.0 0.0.0.255 network 192.168.5.0 0.0.0.255 # ssh authorization-type default aaa # user-interface con 0 # vm-manager # return
學習到的網段:
[~HUAWEI-GE1/0/1]dis ip routing-table Proto: Protocol Pre: Preference Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route ------------------------------------------------------------------------------ Routing Table : _public_ Destinations : 14 Routes : 14 Destination/Mask Proto Pre Cost Flags NextHop Interface 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/24 OSPF 10 4 D 192.168.4.1 Vlanif40 192.168.2.0/30 OSPF 10 3 D 192.168.4.1 Vlanif40 192.168.2.4/30 OSPF 10 2 D 192.168.4.1 Vlanif40 192.168.3.0/24 OSPF 10 2 D 192.168.4.1 Vlanif40 192.168.4.0/24 Direct 0 0 D 192.168.4.2 Vlanif40 192.168.4.2/32 Direct 0 0 D 127.0.0.1 Vlanif40 192.168.4.255/32 Direct 0 0 D 127.0.0.1 Vlanif40 192.168.5.0/24 Direct 0 0 D 192.168.5.1 Vlanif50 192.168.5.1/32 Direct 0 0 D 127.0.0.1 Vlanif50 192.168.5.255/32 Direct 0 0 D 127.0.0.1 Vlanif50 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
總結:
IP段是根據子網掩碼划分的,如果不在同一個vlan中需要用到192.168.2.0段的話 這就要划分出互聯ip,子網掩碼是252的話,就是30位掩碼,這樣划分就是一個網 絡地址一個廣播地址,剩下兩個為可用地址,如果不這樣划分,掩碼是255.255.255.0 的話,在其他vlan段中配置ip的192.168.2.0段ip的話會提示地址沖突(不同交換機) 同一設備不同的口子是直連 優先級:直連 >靜態>動態