R1代码如下
<Huawei>sys
[Huawei]dhcp enable //开启DHCP
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip a 192.168.1.254 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip a 192.168.2.254 24
[Huawei]ip pool 1 //创建地址池
Info: It's successful to create an IP address pool.
[Huawei-ip-pool-1]network 192.168.1.0 mask 255.255.255.0 //规定网段 子网掩码
[Huawei-ip-pool-1]gateway-list 192.168.1.254 //设置网关
[Huawei-ip-pool-1]dns-list 8.8.8.8 //设置DNS
[Huawei-ip-pool-1]lease day 0 hour 12 minute 0 //设置租约12H
[Huawei]ip pool 2
[Huawei-ip-pool-2]network 192.168.2.0 mask 255.255.255.0
[Huawei-ip-pool-2]gateway-list 192.168.2.254
[Huawei-ip-pool-2]dns-list 8.8.8.8
[Huawei-ip-pool-2]lease day 0 hour 12 minute 0
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]dhcp select global
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]dhcp select global
[Huawei]ip pool 2
[Huawei-ip-pool-2]static-bind ip-address 192.168.2.10 mac-address 5489-9882-472D //规定这个MAC值的电脑用192.168.2.10这个IP
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]ip add 192.168.3.1 24
[Huawei]rip 1 //创建RIP
[Huawei-rip-1]version 2 //设置为版本2
[Huawei-rip-1]network 192.168.1.0 //添加直连网段
[Huawei-rip-1]network 192.168.2.0
[Huawei-rip-1]network 192.168.3.0
R2的代码
<Huawei>sys
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.3.2 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.4.1 24
[Huawei]rip 1
[Huawei-rip-1]version 2
[Huawei-rip-1]network 192.168.3.0
[Huawei-rip-1]network 192.168.4.0
R3的代码
<Huawei>sys
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.4.2 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.5.1 24
[Huawei]rip 1
[Huawei-rip-1]version 2
[Huawei-rip-1]network 192.168.4.0
[Huawei-rip-1]network 192.168.5.0
R4的代码
<Huawei>sys
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.5.2 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.10.254 24
[Huawei]rip 1
[Huawei-rip-1]version 2
[Huawei-rip-1]network 192.168.5.0
[Huawei-rip-1]network 192.168.10.0