静态路由、浮动路由配置
在网络设计中,静态路由广泛得应用与点到点的网络连接,在这种静态路由指定数据分组的传输路径和设置路由器的缺省路由。
1. 静态路由的配置方法与步骤
在全局配置模式下,使用”ip route”命令配置静态路由,使用”noip route”命令删除静态路由配置。 命令格式:ip route <目的网络地址><子网掩码><下一跳路由器的IP地址>
2. 浮动静态路由配置方法与步骤
当多条链路带宽差异特别大的时候,我们让高带宽链路成为主链路,低带宽成为备份链路,通过调整静态路由优先级达到链路冗余。默认优先级为60 优先级数值越小,优先级越高。
根据路由的选举规则调整路由的优劣,让高带宽链路更优,一般调整优先级。
路由的选举规则 ①比较掩码长度,越长越优 ②路由优先级,越小越优 ③路由开销值,越小越优路由的选举过程中比较的参数 ①掩码长度:掩码越长表示网段越精确,所以掩码越长越优。 ②路由优先级pre:不同的路由协议拥有不同的优先级,优先级表示通过这种方式学到的路由器的可靠程度,越小越优,直连路由pre为0。 ③路由开销值cost:描述从路由器本地到达目标网段的距离有多远,直连路由位cost为0。
静态路由、浮动路由实验
实验需求: 使用静态路由实现全网互通,要求12.1.1.0/24网段为主链路,21.1.1.0/24为备份链路。 分析:从拓补图中可以看出,左右两边分别是两个单臂路由,根据要求需要将12.1.1.0/24网段为主链路,21.1.1.0/24为备份链路,这里需要设置浮动路由;并用静态路由实现全网互通。
实验一般步骤: 1.配置ip 2.验证直连 3.配置路由协议 4.查看路由表 5.验证网段通信 6.pc测试
代码如下:
R1:
#
sysname R1
#
aaa
authentication
-scheme
default
authorization
-scheme
default
accounting
-scheme
default
domain
default
domain default_admin
local
-user admin password cipher
OOCM4m($F4ajUn1vMEIBNUw#
local
-user admin service
-type http
#
firewall zone
Local
priority
16
#
interface Ethernet0/0/0
ip address
21.1.1.1 255.255.255.0
#
interface Ethernet0/0/1
#
interface Serial0/0/0
link
-protocol ppp
#
interface Serial0/0/1
link
-protocol ppp
#
interface Serial0/0/2
link
-protocol ppp
#
interface Serial0/0/3
link
-protocol ppp
#
interface GigabitEthernet0/0/0
shutdown
ip address
12.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/0.2
shutdown
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/1.1
vlan
-type dot1q
10
ip address
192.168.10.1 255.255.255.0
#
interface GigabitEthernet0/0/1.2
vlan
-type dot1q
20
ip address
192.168.20.1 255.255.255.0
#
interface GigabitEthernet0/0/2
#
interface GigabitEthernet0/0/3
#
wlan
#
interface NULL0
#
ip route
-static 0.0.0.0 0.0.0.0 12.1.1.2
ip route
-static 0.0.0.0 0.0.0.0 21.1.1.2 preference
61
#
user
-interface con
0
idle
-timeout
0 0
user
-interface vty
0 4
user
-interface vty
16 20
#
return
R2:
#
sysname R2
#
aaa
authentication
-scheme
default
authorization
-scheme
default
accounting
-scheme
default
domain
default
domain default_admin
local
-user admin password cipher
OOCM4m($F4ajUn1vMEIBNUw#
local
-user admin service
-type http
#
firewall zone
Local
priority
16
#
interface Ethernet0/0/0
ip address
21.1.1.2 255.255.255.0
#
interface Ethernet0/0/1
#
interface Serial0/0/0
link
-protocol ppp
#
interface Serial0/0/1
link
-protocol ppp
#
interface Serial0/0/2
link
-protocol ppp
#
interface Serial0/0/3
link
-protocol ppp
#
interface GigabitEthernet0/0/0
ip address
12.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address
23.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/2
#
interface GigabitEthernet0/0/3
#
wlan
#
interface NULL0
#
ip route
-static 192.168.10.0 255.255.255.0 12.1.1.1
ip route
-static 192.168.10.0 255.255.255.0 21.1.1.1
ip route
-static 192.168.20.0 255.255.255.0 12.1.1.1
ip route
-static 192.168.20.0 255.255.255.0 21.1.1.1
ip route
-static 192.168.30.0 255.255.255.0 23.1.1.3
ip route
-static 192.168.40.0 255.255.255.0 23.1.1.3
#
user
-interface con
0
user
-interface vty
0 4
user
-interface vty
16 20
#
return
R3:
#
sysname R3
#
aaa
authentication
-scheme
default
authorization
-scheme
default
accounting
-scheme
default
domain
default
domain default_admin
local
-user admin password cipher
OOCM4m($F4ajUn1vMEIBNUw#
local
-user admin service
-type http
#
firewall zone
Local
priority
16
#
interface Ethernet0/0/0
#
interface Ethernet0/0/1
#
interface Serial0/0/0
link
-protocol ppp
#
interface Serial0/0/1
link
-protocol ppp
#
interface Serial0/0/2
link
-protocol ppp
#
interface Serial0/0/3
link
-protocol ppp
#
interface GigabitEthernet0/0/0
ip address
23.1.1.3 255.255.255.0
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/1.1
vlan
-type dot1q
30
ip address
192.168.30.1 255.255.255.0
#
interface GigabitEthernet0/0/1.2
vlan
-type dot1q
40
ip address
192.168.40.1 255.255.255.0
#
interface GigabitEthernet0/0/2
#
interface GigabitEthernet0/0/3
#
wlan
#
interface NULL0
#
ip route
-static 0.0.0.0 0.0.0.0 23.1.1.2
#
user
-interface con
0
idle
-timeout
0 0
user
-interface vty
0 4
user
-interface vty
16 20
#
return
SW1:
#
sysname SW1
#
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
[SW1]int e0
/0/1
[SW1-Ethernet0
/0/1]dis
[SW1-Ethernet0
/0/1]display thi
[SW1-Ethernet0
/0/1]display
this
#
interface Ethernet0/0/1
port link
-type access
port
default vlan
10
#
return
[SW1-Ethernet0
/0/1]int e0
/0/2
[SW1-Ethernet0
/0/2]dis
[SW1-Ethernet0
/0/2]display
this
#
interface Ethernet0/0/2
port link
-type access
port
default vlan
20
#
return
[SW1-Ethernet0
/0/2]int g0
/0/1
[SW1-GigabitEthernet0
/0/1]di
[SW1-GigabitEthernet0
/0/1]display
this
#
interface GigabitEthernet0/0/1
port link
-type trunk
port trunk allow
-pass vlan
2 to
4094
#
return
[SW1-GigabitEthernet0
/0/1]
[SW1-GigabitEthernet0
/0/1]q
[SW1]dis
[SW1]display cu
[SW1]display current
-configuration
#
sysname SW1
#
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 MEth0/0/1
#
interface Ethernet0/0/1
port link
-type access
port
default vlan
10
#
interface Ethernet0/0/2
port link
-type access
port
default vlan
20
#
interface Ethernet0/0/3
#
interface Ethernet0/0/4
#
interface Ethernet0/0/5
#
interface Ethernet0/0/6
#
interface Ethernet0/0/7
#
interface Ethernet0/0/8
#
interface Ethernet0/0/9
#
interface Ethernet0/0/10
#
interface Ethernet0/0/11
#
interface Ethernet0/0/12
#
interface Ethernet0/0/13
#
interface Ethernet0/0/14
#
interface Ethernet0/0/15
#
interface Ethernet0/0/16
#
interface Ethernet0/0/17
#
interface Ethernet0/0/18
#
interface Ethernet0/0/19
#
interface Ethernet0/0/20
#
interface Ethernet0/0/21
#
interface Ethernet0/0/22
#
interface GigabitEthernet0/0/1
port link
-type trunk
port trunk allow
-pass vlan
2 to
4094
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
user
-interface con
0
idle
-timeout
0 0
user
-interface vty
0 4
#
return
SW2:
#
sysname SW2
#
vlan batch
30 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 MEth0/0/1
#
interface Ethernet0/0/1
port link
-type access
port
default vlan
30
#
interface Ethernet0/0/2
port link
-type access
port
default vlan
40
#
interface Ethernet0/0/3
#
interface Ethernet0/0/4
#
interface Ethernet0/0/5
#
interface Ethernet0/0/6
#
interface Ethernet0/0/7
#
interface Ethernet0/0/8
#
interface Ethernet0/0/9
#
interface Ethernet0/0/10
#
interface Ethernet0/0/11
#
interface Ethernet0/0/12
#
interface Ethernet0/0/13
#
interface Ethernet0/0/14
#
interface Ethernet0/0/15
#
interface Ethernet0/0/16
#
interface Ethernet0/0/17
#
interface Ethernet0/0/18
#
interface Ethernet0/0/19
#
interface Ethernet0/0/20
#
interface Ethernet0/0/21
#
interface Ethernet0/0/22
#
interface GigabitEthernet0/0/1
port link
-type trunk
port trunk allow
-pass vlan
2 to
4094
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
user
-interface con
0
idle
-timeout
0 0
user
-interface vty
0 4
#
return