网络知识

发布时间 2023-10-05 15:11:24作者: quls

[Huawei]sysname dyh 改名字

<Huawei>display version 显示vrp版本

<Huawei>display current-configuration 查看交换机配置

使用账户和密码登录终端

  1. <Huawei>system-view

  2. [Huawei]aaa

  3.  

  4. [Huawei-aaa]local-user admin01 password cipher 123 //创建账户叫admin01,密码123

  5. [Huawei-aaa]quit

  6. [Huawei]user-**interface** console 0

  7. [Huawei-ui-console0]authentication-mode aaa //激活配置

    开启DHCP

    dhcp enable 开启dhcp

    ip pool 1 创建地址池 1

    network 10.1.1.0 net 地址池网段

    network 10.1.1.0 mask 255.255.255.0 地址池掩码

    dns-list 10.1.1.1 dns地址

    getway-list 10.1.1.1 网关地址

    excluded-ip-address10.1.1.2 保留地址

    lease day 10 地址租期

    vlan 10

    int g0/0/1

    port link-type access

    port default vlan 10

    int vlanif 10

    ip add 10.1.1.1 24

    dhcp select global 从这个接口可以获得全局DHCP

    网线接接口0/0/1之后电脑自动获取到DHCP

     

access 接入链路

[Huawei]vlan batch 2 to 3 批量创建 批量删除undo vlan batch 2 to 3

[Huawei]undo info-center enable 关闭日志

[Huawei]port-group 1 [Huawei-port-group-1]group-member Ethernet 0/0/3 Ethernet 0/0/4 [Huawei-port-group-1]port link-type access [Huawei-Ethernet0/0/3]port link-type access [Huawei-Ethernet0/0/4]port link-type access [Huawei-port-group-1]port default vlan 2 [Huawei-Ethernet0/0/3]port default vlan 2 [Huawei-Ethernet0/0/4]port default vlan 2

[Huawei-port-group-1]quit

[Huawei]port-group 2 [Huawei-port-group-2]group-member Ethernet 0/0/5 Ethernet 0/0/6 [Huawei-port-group-2]port link-type access [Huawei-Ethernet0/0/5]port link-type access [Huawei-Ethernet0/0/6]port link-type access [Huawei-port-group-2]port default vlan 3 [Huawei-Ethernet0/0/5]port default vlan 3 [Huawei-Ethernet0/0/6]port default vlan 3

 

trunk 交换机连接交换机 中继链路

[Huawei]int e0/0/7 两台机器一样配置 LSW1 [Huawei-Ethernet0/0/7]port link-type trunk 给数据打标记 [Huawei-Ethernet0/0/7]port trunk allow-pass vlan all 允许所有vlan

[Huawei]int e0/0/7 两台机器一样配置 LSW2 [Huawei-Ethernet0/0/7]port link-type trunk 配置为中继链路 [Huawei-Ethernet0/0/7]port trunk allow-pass vlan all 允许放行所有vlan数据

 

冷知识:

如果接口配置混乱,需要还原时

clear configuration interface Ethernet 0/0/7 清空配置

interface ethernet0/0/7 进入接口

undo shutdown 开启接口

 

链路聚合,多条链路网卡捆绑在一起,实现增加可靠性,提高链路带宽的目的

interface eth-trunk 1 创建1号链路聚合接口

trunkport Ethernet 0/0/7 0/0/8 捆绑7,8接口

port link-type trunk

port trunk allow-pass vlan all

 

 

路由器

[Huawei]int g0/0/0 [Huawei-GigabitEthernet0/0/0]ip address 192.168.1.254 24 配接口IP

[Huawei]display ip interface brief 查看IP

undo ip address,IP配置错误可以使用该命令删除

 

<Huawei>display ip routing-table | include /24 查看子网掩码为/24的路由表信息

直连路由

路由器配置vlan

vlan 10 - 创建一个 VLAN(虚拟局域网),VLAN 号为 10

int g0/0/5 - 配置接口为 g0/0/5

portswitch - 配置接口为交换机端口模式

port link-type accessport - 配置接口为访问端口模式

default vlan 10 - 将该接口默认关联到 VLAN 10

路由器配置web管理页面

int g0/0/2

ip add 192.168.1.1 24

dis this

aaa - 开启 AAA 认证功能

local-user admin1 password cipher 123 - 配置本地用户 admin1 的密码(以不可逆方式)

local-user admin1 privilege level 15 - 配置本地用户 admin1 的权限级别为 15(管理员级别)

local-user admin1 service-type http - 配置本地用户 admin1 的服务类型为 http

http server enable - 启用 HTTP 服务器功能

网线连接路由器接口,笔记本网卡地址配置为192.168.1.2 24 ,浏览器访问192.168.1.1

静态路由 由管理员手工配置,添加所需要的路由 ip route-static 目标网段 掩码 下一跳

[Huawei]ip route-static 192.168.3.0 24 192.168.2.2

[Huawei]ip route-static 192.168.1.0 24 192.168.2.1

 

交换机开局配置

以下是对您提供的华为交换机命令的解释:

clock timezone beijing add 08:00

设置时钟时区为北京时间,相对于国际标准时间(GMT)增加8小时。

clock datetime 16:33:30 2021-07-30

设置交换机的日期和时间为2021年7月30日 16点33分30秒。

sys

进入系统视图,用于进行全局配置。

sysname itc01

配置交换机的主机名为itc01。

lldp enable

启用LLDP(链路层发现协议)功能,用于交换机之间的链路信息交换。

dhcp enable

启用DHCP(动态主机配置协议)功能,用于自动分配IP地址给连接到交换机的设备。

dhcp snooping enable

启用DHCP Snooping功能,用于防止非法DHCP服务器对网络的攻击。

stelnet server enable

启用STelnet服务器,用于通过Telnet对交换机进行远程管理。

http server enable	

启用HTTP服务器,用于通过Web界面对交换机进行管理。

http timeout 30	

配置HTTP会话超时时间为30分钟。

ip route-static 0.0.0.0 0.0.0.0 172.16.145.1	

添加静态默认路由,将所有流量发送到网关地址172.16.145.1。

snmp-agent	

进入SNMP Agent视图,用于配置SNMP(简单网络管理协议)功能。

snmp-agent sys-info version v2c	

配置SNMP版本为v2c。

snmp-agent community complexity-check disable	

禁用SNMP community(团体字符串)的复杂性检查。

snmp-agent community write itc	
y	

配置SNMP community为itc并授权读写权限。

aaa	

进入AAA(认证、授权和账户)视图,用于进行认证和授权的配置。

local-user itc password cipher itc@@@@sh privilege level 15

创建本地用户itc,并设置密码为itc@@@@sh(加密后的密码),并赋予最高管理员权限(级别15)。

local-user itc service-type terminal ssh http   
q

配置本地用户itc允许通过SSH和HTTP协议进行终端访问。

ssh user itc authentication-type password

为SSH用户itc配置使用密码进行认证。

ssh server port 12345   
y

配置SSH服务器监听端口号为12345,并确认配置。

user-interface vty 0 4	
authentication-mode aaa	
protocol inbound ssh	
q	

配置虚拟终端(VTY)用户接口范围为0到4,使用AAA认证方式,并允许通过SSH协议进行远程登录。

port-group 1	
  group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/48	
  port link-type trunk	
  port trunk allow-pass vlan all	
  q	

配置端口组1,并将GigabitEthernet 0/0/1到GigabitEthernet 0/0/48加入该组,设置端口链路类型为trunk,并允许所有VLAN通过该trunk端口。

port-group 2	
  group-member XGigabitEthernet 0/0/1 to XGigabitEthernet 0/0/4	
  port link-type trunk	
  port trunk allow-pass vlan all	
  q	

配置端口组2,并将XGigabitEthernet 0/0/1到XGigabitEthernet 0/0/4加入该组,设置端口链路类型为trunk,并允许所有VLAN通过该trunk端口。

vlan 145	
q	

创建VLAN 145。

int vlan 145	
description MGMT IP@2021.7.30	
ip address 172.16.145.12 255.255.255.0
q
q
save
y

 

三层交换机(路由器加交换机,有多个接口并且具备路由功能)

路由设备在第三层,接口可以直接配置IP,交换机不能直接配IP,需要开启虚拟接口

三层交换机接口配置ip思路

创建VLAN

进入该vlan的虚拟接口配置IP

将需要配置IP的接口加入上述vlan

 

[Huawei]undo info-center enable

[Huawei]vlan batch 2 to 3

[Huawei]int g0/0/2 [Huawei-GigabitEthernet0/0/2]port link-type access [Huawei-GigabitEthernet0/0/2]port default vlan 2 [Huawei-GigabitEthernet0/0/2]int g0/0/3 [Huawei-GigabitEthernet0/0/3]port link-type access [Huawei-GigabitEthernet0/0/3]port default vlan 3

[Huawei]int vlanif 1 [Huawei-Vlanif1]ip address 192.168.1.254 24 虚拟接口配置IP

[Huawei]int vlanif 2 [Huawei-Vlanif2]ip add 192.168.2.254 24 [Huawei-Vlanif2]int vlanif 3 [Huawei-Vlanif3]ip add 192.168.3.254 24

[Huawei]display ip interface brief 查看IP

 

[Huawei]vlan batch 2 3 Info: This operation may take a few seconds. Please wait for a moment...done. [Huawei]int e0/0/2 [Huawei-Ethernet0/0/2]port link-type access [Huawei-Ethernet0/0/2]port default vlan 2 [Huawei-Ethernet0/0/2]int e0/0/3 [Huawei-Ethernet0/0/3]port link-type access [Huawei-Ethernet0/0/3]port default vlan 3

<Huawei>display ip routing-table 查看路由

[Huawei]int g0/0/1 [Huawei-GigabitEthernet0/0/1]port link-type trunk [Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all 配置中继,单条线缆通过多个vlan

[Huawei]int e0/0/4 [Huawei-Ethernet0/0/4]port link-type trunk [Huawei-Ethernet0/0/4]port trunk allow-pass vlan all

 

[Huawei]vlan 4 [Huawei-vlan4]int vlanif 4 [Huawei-Vlanif4]ip add 192.168.4.1 24 [Huawei-Vlanif4]quit [Huawei]int g0/0/2 [Huawei-GigabitEthernet0/0/2]port link-type access [Huawei-GigabitEthernet0/0/2]port default vlan 4 [Huawei-GigabitEthernet0/0/2]ping 192.168.4.2

 

三层交换

1.创建vlan

2.进入vlan虚拟接口配置ip

3.将需要配置ip的接口加入vlan

[Huawei]int vlanif 4 [Huawei-Vlanif4]ip add 192.168.1.1 24 [Huawei-Vlanif4]quit [Huawei]int g0/0/1 [Huawei-GigabitEthernet0/0/1]port link-type access [Huawei-GigabitEthernet0/0/1]port default vlan 4

 

动态路由

宣告(不需要手写路由,自动学习能力)

[Huawei]ip route-static 192.168.5.0 24 192.168.4.2

[Huawei]ip route-static 192.168.1.0 24 192.168.4.1

静态,如果多配置几条也能通过,但是现在使用动态路由

ospf (开放式最短路径优先)

适合大型网络

[Huawei]ospf 三层交换机 [Huawei-ospf-1]area 0 [Huawei-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 [Huawei-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255 [Huawei-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255 [Huawei-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255

[Huawei]ospf 路由器 [Huawei-ospf-1]area 0 [Huawei-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255 [Huawei-ospf-1-area-0.0.0.0]network 192.168.5.0 0.0.0.255

display ip routing table 192.168.3.0/24 OSPF 10 2 D 192.168.4.1 GigabitEthernet 0/0/0

[Huawei]display current-configuration

[Huawei-ospf-1-area-0.0.0.0]display this 查看当前配置 [V200R003C00] # area 0.0.0.0 network 192.168.4.0 0.0.0.255 network 192.168.5.0 0.0.0.255

rip

version 2

network 192.168.1.0 0.0.0.255

 

传输层

奠定了端口号 ,一个ip上访问不同业务,需要端口号

网络层提供点到点的连接

传输层通过端对端的连接

TCP

传输控制协议,可靠面向连接的协议 0~65535

传输效率低

21 FTP 文件传输协议 上传下载

22 SSH 远程登录

25 SMTP 简单邮件传输协议

53 DNS 域名解析服务

80 HTTP 超文本传输协议

443 HTTPS 超文本传输协议 附带安全加密功能

三次握手

发送SYN,请求建立连接

发送SYN,ACK

发送ACK

四次断开

发送FIN,请求断开连接

发送ACK

发送FIN,请求断开连接

发送ACk

 

 

UDP

用户数据报协议

不可靠的,无连接的服务

传输效率高

69 TPTP 简单文件传输协议

53 DNS 域名解析

123 NTP 网络时间协议

 

ACL访问控制列表

应用在路由器接口的指令列表

undo info-center enable

int g 0/0/0

ip add 192.168.1/2.254 24

ACL的作用

读取第三场,第四层报文头信息(ip 端口)

基本ACL 2000-2999 源ip

高级ACL 3000-3999 源ip地址 目的ip地址 端口 协议

192.168.2.1

0.0.0.0 0代表的是对应匹配的,255代表的是不匹配,4个0代表四位都匹配必须192.168.2.1 ,如果是0.0.0.255,代表192.168.2.0~255

[Huawei]acl 2000 [Huawei-acl-basic-2000]rule deny source 192.168.2.1 0.0.0.0 acl规则禁止2.1通过 [Huawei-acl-basic-2000]quit [Huawei]int g0/0/1 [Huawei-GigabitEthernet0/0/1]traffic-filter inbound acl 2000 在入接口中应用

[Huawei-acl-basic-2000]undo rule 5 如果规则写错,可以根据规则号码删除

[Huawei-acl-basic-2000]display this

display acl 2000

display acl all

rule 1 deny source 192.168.2.1 0.0.0.0

rule permit source 192.168.2.1 0.0.0.0 = rule permit source 192.168.2.1 0

[Huawei-acl-basic-2000]rule permit source 192.168.2.1 0.0.0.0 放行2.1 [Huawei-acl-basic-2000]rule deny source any 拒绝所有

 

高级ACL 3000~3999 源ip 目标ip 协议 端口号

[Huawei-GigabitEthernet0/0/1]undo traffic-filter inbound

image-20230926184433400

禁止2.2访问1.1的网站服务,但不影响其他服务(tcp 80 )

[Huawei]acl 3000 [Huawei-acl-adv-3000]rule deny tcp source 192.168.2.2 0 destination 192.168.1.1 0 destination-port eq 80 拒绝2.2 访问1.1的tcp的80号端口

[Huawei-GigabitEthernet0/0/1]undo traffic-filter inbound 删除原来有的 [Huawei-GigabitEthernet0/0/1]traffic-filter inbound acl 3000 应用acl 3000

display acl all

禁止2.1访问1.1的ftp服务,但不影响其他服务 (tcp 21)

[Huawei]acl 3000 [Huawei-acl-adv-3000]rule deny tcp source 192.168.2.1 0 destination 192.168.1.1 0 destination-port eq 21

使用acl时,同一个接口的同方向只能一次应用一个acl列表

 

 

 

NAT网络地址转换

广域网 外网

局域网 内网

可以将私有地址转为全球唯一的公有地址

ip地址 32 位 拥有42亿+的数量并且已经枯竭

私有ip地址 (仅限于内网)

A 10.0.0.0~10.255.255.255

B172.16.0.0~172.31.255.255

C192.168.0.0~192.168.255.255

哪台、常用的方法

静态转换 (服务器) 双向通信

 

image-20231002173535200

[Huawei]int g0/0/1 [Huawei-GigabitEthernet0/0/1]nat static global 100.0.0.2 inside 192.168.2.1

[Huawei-GigabitEthernet0/0/1]nat static global 100.0.0.3 inside 192.168.2.2

undo nat static global 100.0.0.2 inside 192.168.2.1 (删除)

easy ip 多对一 单向通信 (一群人需要访问外网)

image-20231002184948744

undo nat static global 100.0.0.2 inside 192.168.2.1 (删除)

undo nat static global 100.0.0.3 inside 192.168.2.2 (删除)

[Huawei]acl 2000 [Huawei-acl-basic-2000]rule 5 permit source any [Huawei-acl-basic-2000]int g0/0/1 [Huawei-GigabitEthernet0/0/1]nat outbound 2000

静态nat

int g0/0/2

nat static global 200.1.1.11 inside 10.1.1.11

nat static global 200.1.1.12 inside 10.1.1.12

easy ip 允许多个内部地址使用一个公网IP

acl 2000

rule 5 permit source 10.1.1.0 0.0.0.255

int g0/0/2

nat outbound 2000

 

VRRP

多网关存在的问题

通过部署多网关的方式实现网关的备份

存在的问题

网关间ip地址冲突

住机会频繁切换网络出口

 

虚拟路由冗余协议

将多个路由器虚拟成一个虚拟路由器,通过配置虚拟路由器的IP地址为默认网关,实现网关的备份

image-20231003105137857

<Huawei>sys [Huawei]sysname sw1

[sw1]undo info enable

[sw1]int vlan 1 [sw1-Vlanif1]ip add 192.168.1.252 24

[sw1-Vlanif1]quit [sw1]vlan 2 [sw1-vlan2]quit [sw1]int vlan 2 [sw1-Vlanif2]ip add 192.168.2.2 24 [sw1-Vlanif2]int g0/0/2 [sw1-GigabitEthernet0/0/2]port link-type access [sw1-GigabitEthernet0/0/2]port default vlan 2

[sw1]ospf [sw1-ospf-1]area 0 [sw1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 [sw1-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255 ospf动态路由宣告

[sw1]int vlan 1 [sw1-Vlanif1]vrrp vrid 1 virtual-ip 192.168.1.254

[sw1-Vlanif1]display vrrp brief 查看vrrp状态,看主 master ,backup备

VRID State Interface Type Virtual IP

1 Master Vlanif1 Normal 192.168.1.254

Total:1 Master:1 Backup:0 Non-active:0

 

[sw1-Vlanif1]vrrp vrid 1 priority 150 修改优先级 [sw1-Vlanif1]display vrrp brief

VRID State Interface Type Virtual IP

1 Master Vlanif1 Normal 192.168.1.254

Total:1 Master:1 Backup:0 Non-active:0

 

sw2

[Huawei]sysname sw2 [sw2]undo in en Info: Information center is disabled. [sw2]int vlan 1 [sw2-Vlanif1]ip add 192.168.1.253 24 [sw2-Vlanif1]quit [sw2]vlan 2 [sw2-vlan2]vlan 3 [sw2-vlan3]in vlan 3 [sw2-Vlanif3]ip add 192.168.3.2 24 [sw2-Vlanif3]int g0/0/2

[sw2-GigabitEthernet0/0/2]port link-type access

[sw2-GigabitEthernet0/0/2]port default vlan 3 [sw2-GigabitEthernet0/0/2]quit

[sw2]ospf [sw2-ospf-1]area 0 [sw2-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 [sw2-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255

[sw2]int vlan 1 [sw2-Vlanif1]vrrp vrid 1 vir [sw2-Vlanif1]vrrp vrid 1 virtual-ip 192.168.1.254

 

路由器

<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]undo in en Info: Information center is disabled. [Huawei]int g0/0/0 [Huawei-GigabitEthernet0/0/0]ip add 192.168.2.1 24 [Huawei-GigabitEthernet0/0/0]int g0/0/1 [Huawei-GigabitEthernet0/0/1]ip add 192.168.3.1 24 [Huawei-GigabitEthernet0/0/1]int g0/0/2 [Huawei-GigabitEthernet0/0/2]ip add 192.168.4.254 24

[route]ospf [route-ospf-1]area 0 [route-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255 [route-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255 [route-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255

vrrp负载均衡

image-20231003132236478

sw1(sw2,sw3,sw4)同理

<Huawei> <Huawei>sys [Huawei]sysname sw1 [sw1]undo in en Info: Information center is disabled. [sw1]port-group 1 创建接口组1 [sw1-port-group-1]group-member g0/0/1 to g0/0/3 将g0/0/1-g0/0/3加入接口组1 [sw1-port-group-1]port link-type trunk 配置这些接口为中继链路 [sw1-GigabitEthernet0/0/1]port link-type trunk [sw1-GigabitEthernet0/0/2]port link-type trunk [sw1-GigabitEthernet0/0/3]port link-type trunk [sw1-port-group-1]port trunk allow-pass vlan all 放行所有vlan的数据 [sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all [sw1-GigabitEthernet0/0/2]port trunk allow-pass vlan all [sw1-GigabitEthernet0/0/3]port trunk allow-pass vlan all

 

sw1 vlan1 主 vlan2 备

sw2 vlan1 备 vlan2 主

[sw1]int vlan 1 [sw1-Vlanif1]vrrp vrid 1 virtual-ip 192.168.1.254 [sw1-Vlanif1]vrrp vrid 1 priority 150 [sw1-Vlanif2]vrrp vrid 2 virtual-ip 192.168.2.254

[sw2]int vlan 1 [sw2-Vlanif1]vrrp vrid 1 virtual-ip 192.168.1.254 [sw2-Vlanif1]int vlan 2 [sw2-Vlanif2]vrrp vrid 2 virtual-ip 192.168.2.254 [sw2-Vlanif2]vrrp vrid 2 priority 150

[sw2-Vlanif2]display vrrp brief

VRID State Interface Type Virtual IP

1 Backup Vlanif1 Normal 192.168.1.254

2 Master Vlanif2 Normal 192.168.2.254

Total:2 Master:1 Backup:1 Non-active:0

 

 

interface valnif 1 配置sw1

ip address 192.168.1.1 255.255.255.0

vrrp vrid 1 virtual-ip 192.168.1.254

vrrp vrid 1 priority 200

interface valnif 1 配置sw2

ip address 192.168.1.2 255.255.255.0

vrrp vrid 1 virtual-ip 192.168.1.254

vrrp vrid 1 priority 150

 

SSH远程登录

首先要拥有一个可以使用的账户

然后定义该账户的privilege level (权限级别)与服务类型

再定义允许登录的用户数量

最后使用stelnet server enable 指令开启服务

 

路由器

image-20231003170450122

<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]sysname route [route]aaa [route-aaa]local-user dyh password cipher 123 创建用户dyh,密码123 Info: Add a new user. [route-aaa]local-user dyh service-type ssh 开启用户ssh服务功能

[route-aaa]local-user dyh privilege level 3 级别3,等于root,默认值为0(参观级别,不能改配置) 1(可以对系统进行简单维护 2 (较高于1)

[route-aaa]quit [route]user-interface vty 0 4 允许登录0 1 2 3 4 ,5个人登录 [route-ui-vty0-4]authentication-mode aaa aaa认证模式

[route-ui-vty0-4]protocol inbound ssh 允许进入设备的协议为ssh [route-ui-vty0-4]quit [route]stelnet server enable 开启远程登录功能 Info: Succeeded in starting the STELNET server. [route]int g0/0/0 [route-GigabitEthernet0/0/0]ip add 192.168.1.1 24 配置ip

交换机(pc)

[sw1]int vlan 1 [sw1-Vlanif1]ip add 192.168.1.2 24 [sw1-Vlanif1]ping 192.168.1.1

[sw1-Vlanif1]quit [sw1]ssh client first-time enable 登录命令 [sw1]stelnet 192.168.1.1 输入ip Please input the username:dyh Trying 192.168.1.1 ... Press CTRL+K to abort Connected to 192.168.1.1 ... The server is not authenticated. Continue to access it? [Y/N] :y Save the server's public key? [Y/N] :y The server's public key will be saved with the name 192.168.1.1. Please wait...

Enter password: <route> //完成

如果在交换机配置远程登录功能,需要比路由器多执行两条命令

【sw1】ssh user dyh authentication-type password //dyh账户远程连接使用ssh协议时要输入密码验证

【sw1】ssh user dyh service-type stelnet //在系统视图指定dyh账户支持的服务类型为stelnet

 

 

 

 

 

网络设备生成密钥对

system rsa local-key-pair create ...... ...... Input the bits in the modulus[default = 2048]:2048 //输入2048开始生成密钥


新建账号

system aaa local-user ssh001 password cipher Huawei local-user ssh001 privilege level 15 local-user ssh001 service-type ssh quit

开启STelnet服务

stelnet server enable

配置SSH用户ssh001的服务类型为stelnet

ssh user ssh001 service-type stelnet

配置SSH用户ssh001的登录认证方式为password

ssh user ssh001 authentication-type password

配置远程访问

user-interface vty 0 4 authentication-mode aaa protocol inbound ssh

连接测试

ssh ssh001@192.168.1.1

ssh client first-time enable

stelnet 192.168.1.1

 

 

 

子网划分

网速

100M 位/s (秒) 12.5M 字节/s(秒)

1000M 位/s (秒) 125M 字节/s (秒)

存储单位

1字节 byte =8 位bit 8倍

2G大片,100M网速,下载需要2.73分钟 2048/12.5/60=2.73min

1KB =1024字节

1MB =1024KB

1GB =1024MB

1TB =1024GB

1PB =1024TB

1EB =1024PB

 

数制 用来计数的方式

二进制 01

八进制 01234567

十进制 0123456789

十六机制 0123456789ABCDEF

 

10B (10)2 二进制

10O (10)8 八进制

10D (10)10 十进制

10H (10)16 十六进制

 

ISP运营商 移动,电信

192.168.1.0/24 私有地址 C类

192.168.2.0

A公司192.168.1.1 --192.168.1.100

B公司192.168.2.101--192.168.2.200

无类网络

 

192.168.1.0

255.255.255.0 网络位(数字1的掩码对应的),主机位(数字0代表的) 24

11111111.11111111.11111111.00000000

十进制与二进制互换的方式

可以利用该数字序列

128 64 32 16 8 4 2 1

5=101 0 0 0 0 0 1 0 1 4+1

8=1000 0 0 0 0 1 0 0 0 8

255=11111111 11111111 全部相加

25=11001 16+8+1

17=10001 16+1

116=1110100 64+32+16+4

1101=13 8+4+1=13

10=2

11111=31 16+8+4+2+1+31

101111=47 32+8+4+2+1=47

11111111.11111111.11111111.10000000 25

 

子网划分,可以将一个网段根据需求划分为若干网段

1.准备网段

192.168.1.0 /24 255.255.255.0

11111111.11111111.11111111.00000000

2.根据公式计算划分过程

2的n次方=要划分的网段数量

n是借用子网掩码主机位的个数

要划分为2段

192.168.1.0--192.168.1.255

2的1次方=2

192.168.1.0 /25 255.255.255.128

11111111.11111111.11111111.10000000

3.将需要划分子网的ip地址转换为二进制

128 64 32 16 8 4 2 1

192.168.1.00000000 第一个网段

255.255.255.10000000 这里的1是根据之前公式计算的n的值

192.168.1.0-192.168.1.127 192.168.1.1-192.168.1.126 /25 开头结尾不用 255.255.255.128

 

192.168.1.10000000 第2个网段

255.255.255.10000000

192.168.1.128-192.168.1.255 192.168.1.129-192.168.1.254 /25 255.255.255.128

 

 

如果要划分4个网段 = 2的2次方,向主机位借两位

192.168.1.0 /26 128+64=192 255.255.255.192

192.168.1.00000000

255.255.255.11000000

192.168.1.0-63 192.168.1.1-62 /26 第一个网段

255.255.255.192

 

192.168.1.01000000

255.255.255.11000000

192.168.1.64-127 192.168.1.65-126 /26 第二个网段

255.255.255.192

 

192.168.1.10000000

255.255.255.11000000

192.168.1.128-191 192.168.1.129-190 /26 第三个网段

255.255.255.192

 

192.168.1.00000000

255.255.255.11000000

192.168.1.192-255 192.168.1.193-254 /26 第四个网段

255.255.255.192

 

128 64 32 16 8 4 2 1

200.50.30.50 /26 255.255.255.192 255.255.255.00000000 划分4个网段

200.50.30.50 /28 255.255.255.240 255.255.255.11110000

分别是

200.50.30.0 0-14

200.50.30.16 17-30

200.50.30.32 33-46

200.50.30.48 49-62

 

 

 

img

 

 

 

<Huawei>sys Enter system view, return user view with Ctrl+Z. [Huawei]undo in en Info: Information center is disabled. [Huawei]sysname sw1

[sw1]vlan batch 2 3 4 Info: This operation may take a few seconds. Please wait for a moment...done. [sw1]int g0/0/2

[sw1-GigabitEthernet0/0/2]port link-type access

[sw1-GigabitEthernet0/0/2]port default vlan 2 [sw1-GigabitEthernet0/0/2]int g0/0/3

[sw1-GigabitEthernet0/0/3]port link-type access

[sw1-GigabitEthernet0/0/3]port default vlan 3 [sw1-GigabitEthernet0/0/3]int g0/0/4

[sw1-GigabitEthernet0/0/4]port link-type access

[sw1-GigabitEthernet0/0/4]port default vlan 4

[sw1-GigabitEthernet0/0/4]int vlan 1 [sw1-Vlanif1]ip add 192.168.0.62 26 [sw1-Vlanif1]int vlan 2 [sw1-Vlanif2]ip add 192.168.0.126 26 [sw1-Vlanif2]int vlan 3 [sw1-Vlanif3]ip add 192.168.0.190 26 [sw1-Vlanif3]int vlan 4 [sw1-Vlanif4]ip add 192.168.0.254 26

 

子网划分的理解

一个/24的网段,四个/26的网段

一个/24的网段,八个/27的网段

 

带宽

在一定时间内通过某一网络连接的信息量

基本单位:比特每秒 bit/s

在计算机软件方面用字节每秒为单位

bit/s

千比特每秒 kbit/s

兆比特每秒 Mbit/s

吉比特每秒 Gbit/s

img

 

存储单位

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0 1 2 4 8 16 32 64 128

子网划分

image-20230920102748694

image-20230920103136801

image-20230920103425049

 

 

防火墙

以下是华为防火墙(例如华为USG系列)的一些常用配置命令:

  1. 基本配置:

    • 进入系统视图:system-view

    • 配置主机名:sysname <hostname>

    • 配置域名服务器:dns resolve <dns-server-ip>

    • 配置NTP服务器:ntp-service unicast-server <ntp-server-ip>

    • 配置SNMP:snmp-agent sys-info version v2c,snmp-agent community read <community-string>,snmp-agent community write <community-string>

  2. 接口配置:

    • 配置接口IP地址:interface <interface-name>,ip address <ip-address> <subnet-mask>

    • 启用接口:interface <interface-name>,undo shutdown

    • 配置接口描述:interface <interface-name>,description <description>

  3. 防火墙策略配置:

    • 创建防火墙区域:firewall zone <zone-name>,add interface <interface-name>

    • 创建安全策略:firewall policy <policy-name>,source <source-zone>,destination <destination-zone>,action permit/deny

  4. NAT配置:

    • 配置静态NAT:nat static <nat-name> <protocol> <original-ip> <global-ip>

    • 配置动态NAT:nat dynamic <nat-name> <protocol> <source-ip> <global-ip>

  5. VPN配置:

    • 配置IPSec VPN隧道:ipsec proposal <proposal-name>,set encryption <encryption-algorithm>,set authentication <authentication-algorithm>,set sa duration <duration>

    • 配置IKE策略:ike proposal <proposal-name>,set encryption <encryption-algorithm>,set authentication <authentication-algorithm>,set dh <dh-group>,set sa duration <duration>

    • 配置VPN实例:ipsec policy <policy-name>,set ike-peer <ike-peer-name>,set ipsec-proposal <ipsec-proposal-name>

  6. 系统管理:

    • 配置管理员用户:local-user <username> password cipher <password> privilege level <level>

    • 配置Telnet/SSH远程登录:user-interface vty 0 4,authentication-mode aaa,protocol inbound telnet/ssh

以上仅是一些常见的配置命令示例,实际使用时请根据具体需求和设备型号进行配置。请注意,配置命令可能会因设备型号和固件版本而有所不同,建议参考华为防火墙的官方文档或使用帮助进行详细配置。

以下是一些华为防火墙(例如华为USG系列)的常用配置命令示例:

  1. 基本配置:

    • 进入系统视图:system-view

    • 配置主机名:sysname Firewall

    • 配置域名服务器:dns resolve 8.8.8.8

    • 配置NTP服务器:ntp-service unicast-server 1.1.1.1

    • 配置SNMP:snmp-agent sys-info version v2c,snmp-agent community read public,snmp-agent community write private

  2. 接口配置:

    • 配置接口IP地址:interface GigabitEthernet 0/0/1,ip address 192.168.1.1 255.255.255.0

    • 启用接口:interface GigabitEthernet 0/0/1,undo shutdown

    • 配置接口描述:interface GigabitEthernet 0/0/1,description LAN

  3. 防火墙策略配置:

    • 创建防火墙区域:firewall zone trust,add interface GigabitEthernet 0/0/1

    • 创建安全策略:firewall policy policy1,source zone trust,destination zone untrust,action permit

  4. NAT配置:

    • 配置静态NAT:nat static 1 tcp 192.168.1.10 80 203.0.113.10 80

    • 配置动态NAT:nat dynamic 1 tcp 192.168.1.0 0.0.0.255 interface

  5. VPN配置:

    • 配置IPSec VPN隧道:ipsec proposal proposal1,set encryption aes256,set authentication sha256,set sa duration 3600

    • 配置IKE策略:ike proposal proposal1,set encryption aes256,set authentication sha256,set dh group5,set sa duration 3600

    • 配置VPN实例:ipsec policy policy1,set ike-peer peer1,set ipsec-proposal proposal1

  6. 系统管理:

    • 配置管理员用户:local-user admin password cipher Huawei@123 privilege level 15

    • 配置Telnet/SSH远程登录:user-interface vty 0 4,authentication-mode aaa,protocol inbound telnet/ssh

以上仅是一些常见的配置命令示例,实际使用时请根据具体需求和设备型号进行配置。请注意,配置命令可能会因设备型号和固件版本而有所不同,建议参考华为防火墙的官方文档或使用帮助进行详细配置。