网络应用基础3
一、远程管理交换机
1、配置IP地址
远程管理需要通过IP地址访问网络设备,交换机的端口默认无法配置IP地址,需要使用虚拟端口Vlanif 1
<SW1>system-view
Enter system view, return user view with Ctrl+Z.
[SW1]interface Vlanif 1 //进入Vlanif 1虚拟接口
[SW1-Vlanif1]ip address 192.168.1.1 24 //配置IP地址为192.168.1.1,子网掩码为24
2、配置远程登录密码
远程登录需要配置VTY接口
VTY是虚拟终端,是一种网络设备远程连接的方式
vty 0 4表示同时开启0-4五个会话,即可最多同时供五个用户进行连接
[SW1]user-interface vty 0 4 //进入用户接口VTY
[SW1-ui-vty0-4]set authentication password cipher 123456 //配置密码为密文123456
[SW1-ui-vty0-4]user privilege level 15 //设置用户权限为15
用户等级权限如下:
- 0 参观,ping、tracert、telnet、display、quit等
- 1 监控,reboot、reset、undo、debugging等
- 2 系统配置,所有配置命令(管理级配置命令除外)
- 315,所有命令(415用于精细化权限管理)
3、远程连接测试
用第三方软件,如SecureCRT、Putty、Xshell等
路由器/交换机自带telnet命令
<SW2>telnet 192.168.1.1 //telnet + 目标主机IP地址
Trying 192.168.1.1 ...
Press CTRL+K to abort
Connected to 192.168.1.1 ...
Login authentication
Password: //输入密码
Info: The max number of VTY users is 5, and the number
of current VTY users on line is 1.
The current login time is 2023-11-23 19:57:58.
<SW1> //主机名已从SW2变为SW1
二、路由介绍
1、什么是路由
数据从一个网络到达另外一个网络之间转发数据包的过程称为路由
2、什么是路由器
连接不同网络,实现不同网段之间的通信
-
负责在不同网络之间转发数据的设备
-
路由器决定到达目标的路径
-
路由器也为直连网络的主机充当网关角色
-
路由器是实现网络互通的核心设备
3、什么是路由表
路由器选择数据的传输路径的依据
三、路由器工作原理
1、路由器工作原理简述
每台路由器维护一份路由表,路由表记录着:
- 要访问XX网段应从哪个接口发送数据
- 可到达的下一个路由器(主机)的地址
路由器如何工作?
-
路由器接收数据包
-
检查数据包中的目标IP
-
在路由表中查找与目标IP相匹配的路由条目
-
路由表中找到与目标IP相匹配的路由条目后,按照此条目所指的方向将数据转发出去
四、路由表基本配置
1、配置设备名、接口地址
配置设备名(sysname)
配置接口地址(ip address IP地址 子网掩码)
<Huawei>u t m //取消终端提示消息
Info: Current terminal monitor is off.
<Huawei>system-view //进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1 //将路由器改名为R1
[R1]interface GigabitEthernet 0/0/0 //进入GE0/0/0端口
[R1-GigabitEthernet0/0/0]ip address 192.168.1.254 24 //配置IP地址为192.168.1.254 子网掩码为255.255.255.0
2、保存路由器配置
保存路由器配置(save)
<R1>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y //提示配置将被写入设备,是否继续,输入y继续
It will take several minutes to save configuration file, please wait.......
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
<R1>
大多数通用操作与交换机配置相同
五、直连路由
1、什么是直连路由
直连路由是指路由器接口所连接的网络段
2、路由器组网示例
PC1配置:
PC2配置:
PC3配置:
PC4配置:
路由器R1配置:
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.2.254 24
[R1-GigabitEthernet0/0/0]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.1.254 24
验证连通性:PC1 ping PC2、PC3、PC4
PC>ping 192.168.1.2
Ping 192.168.1.2: 32 data bytes, Press Ctrl_C to break
From 192.168.1.2: bytes=32 seq=1 ttl=128 time=47 ms
From 192.168.1.2: bytes=32 seq=2 ttl=128 time=31 ms
From 192.168.1.2: bytes=32 seq=3 ttl=128 time=31 ms
--- 192.168.1.2 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/36/47 ms
PC>ping 192.168.2.1
Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
From 192.168.2.1: bytes=32 seq=3 ttl=127 time=62 ms
From 192.168.2.1: bytes=32 seq=4 ttl=127 time=63 ms
From 192.168.2.1: bytes=32 seq=5 ttl=127 time=62 ms
--- 192.168.2.1 ping statistics ---
5 packet(s) transmitted
3 packet(s) received
40.00% packet loss
round-trip min/avg/max = 0/62/63 ms
PC>ping 192.168.2.2
Ping 192.168.2.2: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.2: bytes=32 seq=2 ttl=127 time=47 ms
From 192.168.2.2: bytes=32 seq=3 ttl=127 time=62 ms
--- 192.168.2.2 ping statistics ---
3 packet(s) transmitted
2 packet(s) received
33.33% packet loss
round-trip min/avg/max = 0/54/62 ms
3、查看路由表
查看路由表 display ip routing-table
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
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
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet //通往1.0网段找1.254地址,从0/0/1接口出去
0/0/1
192.168.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.2.0/24 Direct 0 0 D 192.168.2.254 GigabitEthernet //通往2.0网段找2.254地址,从0/0/0接口出去
0/0/0
192.168.2.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
六、远程管理路由器
1、配置远程登录
远程登录需要配置VTY接口
VTY是虚拟终端,是一种网络设备远程连接的方式
vty 0 4表示同时开启0-4五个会话,即可最多同时供五个用户进行连接
[R1]user-interface vty 0 4 //进入用户接口VTY
[R1-ui-vty0-4]set authentication password cipher 123456 //配置密码为密文123456
[R1-ui-vty0-4]user privilege level 15 //设置用户权限为15
用户等级权限如下:
- 0 参观,ping、tracert、telnet、display、quit等
- 1 监控,reboot、reset、undo、debugging等
- 2 系统配置,所有配置命令(管理级配置命令除外)
- 315,所有命令(415用于精细化权限管理)
2、远程连接测试
用第三方软件,如SecureCRT、Putty、Xshell等
路由器/交换机自带telnet命令
<SW1>telnet 192.168.1.1 //telnet + 目标主机IP地址
Trying 192.168.1.1 ...
Press CTRL+K to abort
Connected to 192.168.1.1 ...
Login authentication
Password: //输入密码
Info: The max number of VTY users is 5, and the number
of current VTY users on line is 1.
The current login time is 2023-11-23 19:57:58.
<R1> //主机名已从SW1变为R1