路由设备:
- 三层交换
- 路由器
路由:
- 将数据包从一个网络发送到另一个网络
路由器:
- 将数据包从一个网络发送到另一个网络的设备
路由器工作原理:
- 根据路由表选择最佳的路径
路由表的形成:
- 直连路由
- 由链路层协议发现的路由
- 配置接口IP地址
- 并且接口状态up
- 静态路由
- 由网络管理员手动配置的路由
- 通信双方的路由器都要配置
- 默认路由是一种特殊的静态路由
- 默认路由目标网络为 0.0.0.0 0.0.0.0
- ip route-static 0.0.0.0 0.0.0.0 192.168.3.1
- 防止路由环路
- 动态路由
- 由动态路由协议发现的路由(rip ospf bgp)
配置案例:
直连路由:
AR1:
[Huawei]sys
[Huawei]sysname AR1
[AR1]interface GigabitEthernet 0/0/0
[AR1-GigabitEthernet0/0/0]ip address 172.16.2.1 24
AR2:
[Huawei]sys
[Huawei]sysname AR2
[AR2]interface GigabitEthernet 0/0/0
[AR2-GigabitEthernet0/0/0]ip address 172.16.2.2 24
两台路由器互相ping 通
[AR1]ping 172.16.2.2
PING 172.16.2.2: 56 data bytes, press CTRL_C to break
Reply from 172.16.2.2: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 172.16.2.2: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 172.16.2.2: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 172.16.2.2: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 172.16.2.2: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 172.16.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/24/30 ms
<R2>ping 172.16.2.1
PING 172.16.2.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.2.1: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 172.16.2.1: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 172.16.2.1: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 172.16.2.1: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 172.16.2.1: bytes=56 Sequence=5 ttl=255 time=30 ms
--- 172.16.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/24/30 ms
配置静态路由:
实现不同网段互通
[AR1]ip route-static 172.16.1.0 24 172.16.2.2
[AR3]ip route-static 172.16.2.0 24 172.16.1.1