Password: //输入密码 Info: The max number of VTY users is 5, and the number ofcurrent VTY users on line is 1. Thecurrent login time is 2023-11-23 19:57:58. <SW1>//主机名已从SW2变为SW1
路由介绍
什么是路由器
负责在不同网络之间转发数据的设备
路由器决定到达目标的路径
路由器也为直连网络的主机充当”网关”角色
路由器是实现网络互连的核心设备
路由器工作原理
路由器工作原理简述
每台路由器维护一份路由表,路由表记录着:
要访问XX网段应从哪个接口发送数据
可到达的下一个路由器(主机)的地址
路由器如何工作?
路由器接收数据包
检查数据包中的目标IP
在路由表中查找与目标IP相匹配的路由条目
路由表中找到与目标IP相匹配的路由条目后,按照此条目所指的方向将数据转发出去
路由表基本配置
配置设备名、接口地址
配置设备名(sysname)
配置接口地址(ip address IP地址 子网掩码)
1 2 3 4 5 6 7
<Huawei>ut m //取消终端提示消息 Info: Current terminal monitor is off. <Huawei>system-view//进入系统视图 Entersystem view, return user view with Ctrl+Z. [Huawei]sysnameR1 //将路由器改名为R1 [R1]interfaceGigabitEthernet 0/0/0 //进入GE0/0/0端口 [R1-GigabitEthernet0/0/0]ipaddress 192.168.1.254 24 //配置IP地址为192.168.1.254 子网掩码为255.255.255.0
保存路由器配置
保存路由器配置(save)
大多数通用操作与交换机配置相同
1 2 3 4 5 6 7
<R1>save Thecurrent configuration will be written to the device. Areyou sure to continue? (y/n)[n]:y //提示配置将被写入设备,是否继续,输入y继续 Itwill take several minutes to save configuration file, please wait....... Configurationfile had been saved successfully Note: The configuration file will take effect after being activated <R1>
直连路由
什么是直连路由
直连路由是指路由器接口所连接的网络段
路由器组网示例
多网段互连
教学部、市场部各自有独立网段,如何实现互连?
PC1配置:
PC2配置:
PC3配置:
PC4配置:
路由器R1配置:
1 2 3 4 5 6 7 8 9
<Huawei>ut m Info: Current terminal monitor is off. <Huawei>system-view Entersystem view, return user view with Ctrl+Z. [Huawei]sysnameR1 [R1]interfaceGigabitEthernet 0/0/0 [R1-GigabitEthernet0/0/0]ipaddress 192.168.2.254 24 [R1-GigabitEthernet0/0/0]interfaceGigabitEthernet 0/0/1 [R1-GigabitEthernet0/0/1]ipaddress 192.168.1.254 24
[R1]displayip routing-table RouteFlags: R - relay, D - download to fib ------------------------------------------------------------------------------ RoutingTables: Public Destinations : 10 Routes : 10
Destination/MaskProto Pre Cost Flags NextHop Interface
127.0.0.0/8Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32Direct 0 0 D 127.0.0.1 InLoopBack0 127.255.255.255/32Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/24Direct 0 0 D 192.168.1.254 GigabitEthernet0/0/1 //通往1.0网段找1.254地址,从0/0/1接口出去
192.168.1.254/32Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.1.255/32Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.2.0/24Direct 0 0 D 192.168.2.254 GigabitEthernet0/0/0 //通往2.0网段找2.254地址,从0/0/0接口出去
192.168.2.254/32Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0 192.168.2.255/32Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0 255.255.255.255/32Direct 0 0 D 127.0.0.1 InLoopBack0
Password: //输入密码 Info: The max number of VTY users is 5, and the number ofcurrent VTY users on line is 1. Thecurrent login time is 2023-11-23 19:57:58. <R1>//主机名已从SW1变为R1