一、VRRP1.1VRRP工作原理
(1)VRRP:Virtual Router Redundancy Protocol,即虚拟路由器冗余协议。
(2)利用VRRP,一组路由器协同工作,但只有一个处于master状态,处于该状态的路由器(的接口)承担实际的数据流量转发任务。在一个VRRP组内的多个路由器接口共用一个虚拟IP地址,该地址被作为局域网内所有主机的缺省网关地址。
(3)VRRP决定哪个路由器是Master,Master路由器负责接收发送至用户网关的数据包并进行转发,以及相应PC对于其网关IP地址的ARP请求。
(4)Backup路由器侦听Master路由器的状态,并在Master路由器发生故障时,接替其工作,从而保证业务流量的平滑切换
1.2VRRP主备切换过程
(1)设置了优先级优先级大的优先优先级一样的时候比较接口的mac地址
(2)路由器配置好以后,互相是不知道对面的配置,会互相发送通告报文,选举主备路由器
(3)选举出主备路由器
(4)选举出主备后, backup 就不再发送报文
(5)master 始终在周期性发送通告报文
(6)master发生故障,主备切换过程
(7)原来的主路由器恢复,则主备回切
1.3VRRP基本配置
拓扑图:
实验结果:
抓包VRRP:
代码:
R1:
u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.10.30 24
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.20.10 24
[R1-GigabitEthernet0/0/1]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0] vrrp vrid 1 virtual-ip 192.168.10.1 #设置为1组 配置虚拟网关
[R1-GigabitEthernet0/0/0]vrrp vrid 1 priority 120 #配置优先级为120
[R1-GigabitEthernet0/0/0]vrrp vrid 1 preempt-mode timer delay 5 #延时抢占5秒
[R1-GigabitEthernet0/0/0]vrrp vrid 1 track interface g0/0/1 reduced 30 #监听上行端口,如果上行端口断开master优先级将30
[R1-GigabitEthernet0/0/0]dis th #查看当前窗口配置
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 192.168.10.30 255.255.255.0
vrrp vrid 1 virtual-ip 192.168.10.1
vrrp vrid 1 priority 120
vrrp vrid 1 preempt-mode timer delay 5
vrrp vrid 1 track interface GigabitEthernet0/0/1 reduced 30
#
return
[R1]ip route-static 192.168.10.0 24 192.168.20.20#添加路由去往10网段,子网掩码,吓一跳
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]q
[R1]ip route-static 192.168.40.0 24 192.168.20.20
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]shutdown
[R1-GigabitEthernet0/0/1]undo shutdown
R2:
u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R2
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 192.168.10.40 24
[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.30.10 24
[R2-GigabitEthernet0/0/1]q
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]vrrp vrid 1 virtual-ip 192.168.10.1 #设置为1组 配置虚拟网关
[R2-GigabitEthernet0/0/0]dis th
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 192.168.10.40 255.255.255.0
vrrp vrid 1 virtual-ip 192.168.10.1
#
return
[R2-GigabitEthernet0/0/0]q
[R2]ip route-static 192.168.40.0 24 192.168.30.20
R3:
u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R3
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.20.20 24
[R3-GigabitEthernet0/0/1]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.30.20 24
[R3-GigabitEthernet0/0/0]q
[R3]int LoopBack #进入回环地址接口也就是自己的接口
[R3-LoopBack1]ip add 192.168.40.10 24 #设置路由
[R3-LoopBack1]dis th
[V200R003C00]
#
interface LoopBack1
ip address 192.168.40.10 255.255.255.0
#
return
[R3-LoopBack1]q
[R3]ip route-static 192.168.10.0 24 192.168.20.10 #添加主路由到10段,子网掩码,下一跳
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]dis th
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 192.168.30.10 255.255.255.0
#
return
[R3]ip route-static 192.168.10.0 24 192.168.30.10 preference 70 #添加备路由,到10段,子网掩码,下一跳,优先级10
二、DHCP2.1DHCP优点
(1)减少工作量
(2)减少出错,出现IP地址冲突
(3)节约地址
(4)简单
2.2DHCP基本原理
2.3DHCP报文类型
2.4DHCP基本配置
拓扑图:
实验结果:
实验代码:
u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1
[R1]dhcp enable #开启dhcp功能
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]int g0/0/0 #进入接口
[R1-GigabitEthernet0/0/0]ip add 192.168.1.254 24 #添加网关,并且规定了地址范围
[R1-GigabitEthernet0/0/0]dhcp select interface #选择接口模式
[R1-GigabitEthernet0/0/0]dhcp server lease day 10 #设置租期10天
[R1-GigabitEthernet0/0/0]dhcp server dns-list 8.8.8.8 #设置dns