IPv4(Internet Protocol Version 4网络协议版本4)协议族是TCP/IP协议族中最为核心的协议族。它工作在TCP/IP协议栈的网络层,提供了无连接数据传输服务。这也是新手宝宝必须要了解和掌握的。
一、IP地址基本概念
1.1 IP地址概述
- 网络层位于数据链路层与传输层之间。网络层中包含了许多协议,其中最重要的协议就是IP。网络层提供了IP路由功能。
- IP地址由32位的二进制组成,为了方便记忆,8位为一段,以点进行分隔,共计四段,转换为十进制。
1.2 IP地址专业术语
- 网络部分:用于标识一个网段。
- 主机部分:用于区分一个网络内的不同主机,表示在这个网段内主机的唯一性。
- 子网掩码:用于区分地址是否在同一个网段。
- 广播地址:用于想该网络中所有主机发送数据的特殊地址。
1.3 私有地址分类
类型 | 范围 |
A | 10.0.0.0~10.255.255.255 |
B | 172.16.0.0~172.31.255.255 |
C | 192.168.0.0~192.168.255.255 |
二、实验配置
2.1 实验目的
掌握接口IPv4的配置方法。
2.2 拓扑图展示
2.3 实验步骤
R1路由器配置如下:
<Huawei>system-view //进入系统视图
[Huawei]undo info-center enable //关闭路由器输出信息
[Huawei]sysname R1 //修改设备名为R1
[R1]display ip interface brief //查看路由器接口信息
*down: administratively down #*号表示该接口被手动关闭,如命令shutdown
^down: standby #^代表该接口是备份接口
(l): loopback #(l)代表环回
(s): spoofing #(s)代表欺骗
The number of interface that is UP in Physical is 2 #表示物理状态UP的接口数量为2
The number of interface that is DOWN in Physical is 1 #表示物理状态DOWN的接口为1
The number of interface that is UP in Protocol is 1 #表示协议状态UP的接口数量为1
The number of interface that is DOWN in Protocol is 2 #表示协议状态DOWN的接口为2
接口名 IP地址/子网掩码 物理状态 协议状态
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned up down
GigabitEthernet0/0/1 unassigned down down
NULL0 unassigned up up(s)
[R1]interface GigabitEthernet 0/0/0 //进入GigabitEthernet 0/0/0接口
[R1-GigabitEthernet0/0/0]ip address 192.168.12.1 24 //配置IP地址和子网掩码
[R1-GigabitEthernet0/0/0]undo shutdown //打开接口
[R1-GigabitEthernet0/0/0]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 1
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.12.1/24 up up
GigabitEthernet0/0/1 unassigned down down
NULL0 unassigned up up(s)
R2路由器配置如下:
<Huawei>system-view
[Huawei]undo info-center enable
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 192.168.12.2 24
[R2-GigabitEthernet0/0/1]undo shutdown
[R2-GigabitEthernet0/0/1]display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 1
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 192.168.12.2/24 up up
NULL0 unassigned up up(s)
[Huawei-GigabitEthernet0/0/1]ping 192.168.12.1 //可以ping通R1的接口地址。
PING 192.168.12.1: 56 data bytes, press CTRL_C to break
Reply from 192.168.12.1: bytes=56 Sequence=1 ttl=255 time=140 ms
Reply from 192.168.12.1: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 192.168.12.1: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 192.168.12.1: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 192.168.12.1: bytes=56 Sequence=5 ttl=255 time=30 ms
--- 192.168.12.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/46/140 ms
三、技术要点
以上是华为路由器地址配置的基本操作,都属于入门级基础。华为设备上支持两种配置子网掩码的方式。
第一种是点份十进制:ip address 192.168.12.1 255.255.255.0
第二种是前缀长度:ip address 192.168.12.1 24
关注+点赞+评论+收藏,分享更多网工实验小技巧。