华为交换机配置静态路由

组网需求:

处于不同交换机下(不同网段)的PC机,相互进行通信

华为交换机配置静态路由_第1张图片

配置思路

采用如下的思路配置IPv4静态路由:

  1. 创建VLAN并配置各接口所属VLAN,配置各VLANIF接口的IP地址,实现相邻设备网络互通。
  2. 在各主机上配置IP缺省网关,在各台Switch上配置IPv4静态路由或者静态缺省路由,实现不配置动态路由协议,使不同网段的任意两台主机之间能够互通

路由信息:

SW1:

ip route-static 0.0.0.0 0.0.0.0 10.2.4.2

SW2:
ip route-static 10.1.1.0 255.255.255.248 10.2.4.1
ip route-static 10.1.2.0 255.255.255.248 10.2.4.6
ip route-static 10.1.3.0 255.255.255.248 10.2.4.10
SW3:
ip route-static 0.0.0.0 0.0.0.0 10.2.4.5
SW4:
ip route-static 0.0.0.0 0.0.0.0 10.2.4.9

SW1配置,其它类似:

[SW1] sysname SW1

[SW1] vlan batch 10 30

[SW1] interface Vlanif 10

[SW1] ip address 10.2.4.1 255.255.255.252

[SW1] dhcp enable

[SW1] interface Vlanif 30

[SW1] ip address 10.1.1.1 255.255.255.248

[SW1] port-group vlan30

[SW1] group-member GigabitEthernet0/0/1 to GigabitEthernet0/0/5

[SW1] port link-type access

[SW1] port default vlan 30

[SW1] interface Eth-Trunk 1

[SW1] mode lacp-static

[SW1] trunkport GigabitEthernet 0/0/23 to 0/0/24

[SW1] port link-type trunk

[SW1] port trunk allow-pass vlan 10

[SW1] ip route-static 0.0.0.0 0.0.0.0 10.2.4.2

save

 

测试:

华为交换机配置静态路由_第2张图片

查看SW2路由表:

dis ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 11       Routes : 11       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       10.1.1.0/29  Static  60   0          RD   10.2.4.1        Vlanif10
       10.1.2.0/29  Static  60   0          RD   10.2.4.6        Vlanif20
       10.1.3.0/29  Static  60   0          RD   10.2.4.10       Vlanif40
       10.2.4.0/30  Direct  0    0           D   10.2.4.2        Vlanif10
       10.2.4.2/32  Direct  0    0           D   127.0.0.1       Vlanif10
       10.2.4.4/30  Direct  0    0           D   10.2.4.5        Vlanif20
       10.2.4.5/32  Direct  0    0           D   127.0.0.1       Vlanif20
       10.2.4.8/30  Direct  0    0           D   10.2.4.9        Vlanif40
       10.2.4.9/32  Direct  0    0           D   127.0.0.1       Vlanif40
      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

SW1配置文件:

[SW1]dis current-configuration 
#
sysname SW1
#
vlan batch 10 30
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
dhcp enable
#
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

Oct 29 2019 10:42:51-08:00 SW1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.
191.3.1 configurations have been changed. The current change number is 26, the ch
ange loop count is 0, and the maximum number of records is 4095. local-user admin service-type http
#
interface Vlanif1
#
interface Vlanif10
 ip address 10.2.4.1 255.255.255.252
#
interface Vlanif30
 ip address 10.1.1.1 255.255.255.248
 dhcp select interface
#
interface MEth0/0/1
#
interface Eth-Trunk1
 port link-type trunk
 port trunk allow-pass vlan 10
 mode lacp-static
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 30
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 30
#
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 30
#
interface GigabitEthernet0/0/4
 port link-type access
 port default vlan 30
#
interface GigabitEthernet0/0/5
 port link-type access
 port default vlan 30
#
interface GigabitEthernet0/0/6
#
interface GigabitEthernet0/0/7
#
interface GigabitEthernet0/0/8
#
interface GigabitEthernet0/0/9
#
interface GigabitEthernet0/0/10
#
interface GigabitEthernet0/0/11
#
interface GigabitEthernet0/0/12
#
interface GigabitEthernet0/0/13
#
interface GigabitEthernet0/0/14
#
interface GigabitEthernet0/0/15
#
interface GigabitEthernet0/0/16
#
interface GigabitEthernet0/0/17
#
interface GigabitEthernet0/0/18
#
interface GigabitEthernet0/0/19
#
interface GigabitEthernet0/0/20
#
interface GigabitEthernet0/0/21
#
interface GigabitEthernet0/0/22
#
interface GigabitEthernet0/0/23
 eth-trunk 1
#
interface GigabitEthernet0/0/24
 eth-trunk 1
#
interface NULL0
#
ip route-static 0.0.0.0 0.0.0.0 10.2.4.2
#
user-interface con 0
user-interface vty 0 4
#
port-group vlan30
 group-member GigabitEthernet0/0/1
 group-member GigabitEthernet0/0/2
 group-member GigabitEthernet0/0/3
 group-member GigabitEthernet0/0/4
 group-member GigabitEthernet0/0/5
#
return

SW2配置文件:

[SW2]dis current-configuration 
#
sysname SW2
#
vlan batch 10 20 40
#
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 10.2.4.2 255.255.255.252
#
interface Vlanif20
 ip address 10.2.4.5 255.255.255.252
#
interface Vlanif40
 ip address 10.2.4.9 255.255.255.252
#
interface MEth0/0/1
#
interface Eth-Trunk1
 port link-type trunk
 port trunk allow-pass vlan 10
 mode lacp-static
#
interface Eth-Trunk2
 port link-type trunk
 port trunk allow-pass vlan 20
 mode lacp-static
#
interface Eth-Trunk3
 port link-type trunk
 port trunk allow-pass vlan 40
 mode lacp-static
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/2
#
interface GigabitEthernet0/0/3
#
interface GigabitEthernet0/0/4
#
interface GigabitEthernet0/0/5
#
interface GigabitEthernet0/0/6
#
interface GigabitEthernet0/0/7
#
interface GigabitEthernet0/0/8
#
interface GigabitEthernet0/0/9
#
interface GigabitEthernet0/0/10
#
interface GigabitEthernet0/0/11
#
interface GigabitEthernet0/0/12
#
interface GigabitEthernet0/0/13
#
interface GigabitEthernet0/0/14
#
interface GigabitEthernet0/0/15
#
interface GigabitEthernet0/0/16
#
interface GigabitEthernet0/0/17
#
interface GigabitEthernet0/0/18
#
interface GigabitEthernet0/0/19
 eth-trunk 2
#
interface GigabitEthernet0/0/20
 eth-trunk 2
#
interface GigabitEthernet0/0/21
 eth-trunk 3
#
interface GigabitEthernet0/0/22
 eth-trunk 3
#
interface GigabitEthernet0/0/23
 eth-trunk 1
#
interface GigabitEthernet0/0/24
 eth-trunk 1
#
interface NULL0
#
ip route-static 10.1.1.0 255.255.255.248 10.2.4.1
ip route-static 10.1.2.0 255.255.255.248 10.2.4.6
ip route-static 10.1.3.0 255.255.255.248 10.2.4.10
#
user-interface con 0
user-interface vty 0 4
#
return

SW3配置文件:

[SW3]dis current-configuration 
#
sysname SW3
#
vlan batch 20 50
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
dhcp enable
#
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 Vlanif20
 ip address 10.2.4.6 255.255.255.252
#
interface Vlanif50
 ip address 10.1.2.1 255.255.255.248
 dhcp select interface
#
interface MEth0/0/1
#
interface Eth-Trunk1
 port link-type trunk
 port trunk allow-pass vlan 20
 mode lacp-static
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 50
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 50
#
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 50
#
interface GigabitEthernet0/0/4
 port link-type access
 port default vlan 50
#
interface GigabitEthernet0/0/5
 port link-type access
 port default vlan 50
#
interface GigabitEthernet0/0/6
#
interface GigabitEthernet0/0/7
#
interface GigabitEthernet0/0/8
#
interface GigabitEthernet0/0/9
#
interface GigabitEthernet0/0/10
#
interface GigabitEthernet0/0/11
#
interface GigabitEthernet0/0/12
#
interface GigabitEthernet0/0/13
#
interface GigabitEthernet0/0/14
#
interface GigabitEthernet0/0/15
#
interface GigabitEthernet0/0/16
#
interface GigabitEthernet0/0/17
#
interface GigabitEthernet0/0/18
#
interface GigabitEthernet0/0/19
#
interface GigabitEthernet0/0/20
#
interface GigabitEthernet0/0/21
#
interface GigabitEthernet0/0/22
#
interface GigabitEthernet0/0/23
 eth-trunk 1
#
interface GigabitEthernet0/0/24
 eth-trunk 1
#
interface NULL0
#
ip route-static 0.0.0.0 0.0.0.0 10.2.4.5
#
user-interface con 0
user-interface vty 0 4
#
port-group vlan50
 group-member GigabitEthernet0/0/1
 group-member GigabitEthernet0/0/2
 group-member GigabitEthernet0/0/3
 group-member GigabitEthernet0/0/4
 group-member GigabitEthernet0/0/5
#

SW4配置文件:

[SW4]dis cur
#
sysname SW4
#
vlan batch 40 60
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
dhcp enable
#
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 Vlanif40
 ip address 10.2.4.10 255.255.255.252
#
interface Vlanif60
 ip address 10.1.3.1 255.255.255.248
 dhcp select interface
#
interface MEth0/0/1
#
interface Eth-Trunk1
 port link-type trunk
 port trunk allow-pass vlan 40
 mode lacp-static
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 60
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 60
#
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 60
#
interface GigabitEthernet0/0/4
 port link-type access
 port default vlan 60
#
interface GigabitEthernet0/0/5
 port link-type access
 port default vlan 60
#
interface GigabitEthernet0/0/6
#
interface GigabitEthernet0/0/7
#
interface GigabitEthernet0/0/8
#
interface GigabitEthernet0/0/9
#
interface GigabitEthernet0/0/10
#
interface GigabitEthernet0/0/11
#
interface GigabitEthernet0/0/12
#
interface GigabitEthernet0/0/13
#
interface GigabitEthernet0/0/14
#
interface GigabitEthernet0/0/15
#
interface GigabitEthernet0/0/16
#
interface GigabitEthernet0/0/17
#
interface GigabitEthernet0/0/18
#
interface GigabitEthernet0/0/19
#
interface GigabitEthernet0/0/20
#
interface GigabitEthernet0/0/21
#
interface GigabitEthernet0/0/22
#
interface GigabitEthernet0/0/23
 eth-trunk 1
#
interface GigabitEthernet0/0/24
 eth-trunk 1
#
interface NULL0
#
ip route-static 0.0.0.0 0.0.0.0 10.2.4.9
#
user-interface con 0
user-interface vty 0 4
#
port-group vlan60
 group-member GigabitEthernet0/0/1
 group-member GigabitEthernet0/0/2
 group-member GigabitEthernet0/0/3
 group-member GigabitEthernet0/0/4
 group-member GigabitEthernet0/0/5
#
return

 

 

 

 

 

 

你可能感兴趣的:(网络,#交换机,静态路由,交换机,华为)