03 (Optional) Configuring Automatic Enterprise Network O&M
03 (Optional) Configuring Automatic Enterprise Network O&M
03 (Optional) Configuring Automatic Enterprise Network O&M
Network O&M
Student Version
and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.
All other trademarks and trade names mentioned in this document are the property of their
respective holders.
Notice
The purchased products, services and features are stipulated by the contract made between
Huawei and the customer. All or part of the products, services and features described in this
document may not be within the purchase scope or the usage scope. Unless otherwise
specified in the contract, all statements, information, and recommendations in this
document are provided "AS IS" without warranties, guarantees or representations of any
kind, either express or implied.
The information in this document is subject to change without notice. Every effort has been
made in the preparation of this document to ensure accuracy of the contents, but all
statements, information, and recommendations in this document do not constitute a
warranty of any kind, express or implied.
Website: https://e.huawei.com/
1 Configuring Automatic
Enterprise Network O&M
1.1 Background
1.2 Objectives
Upon completion of this task, you will be able to:
● Learn how to use python to compile a password change script
● Learn how to use python to compile a configuration backup script.
● Learn how to use python to configure a scheduled task
1.3 Topology
2 Lab Topology
The three office areas can communicate with each other. OSPF routes are
configured for the router in each single area so that all PCs in the office
areas can communicate with each other. SSH is enabled on all network
devices. A network management PC is deployed in the Technology
department to ensure normal communication between the network
management PC and network devices.
The IP address planning and interface planning can be referred in the
appendix.
2.1 Implementation
2.1.1 Roadmap
1. Configure router interfaces.
2. Deploy a single-area OSPF network.
3. Configure SSH login on the routers.
4. Install the Paramiko module on the network management PC.
5. Use Python to compile a password change script.
6. Use Python to compile a configuration backup script.
7. Configure a scheduled task.
8. Configure IP addresses for all the PCs.
2.1.2 Procedure
#Configure R1.
[Huawei]system-view
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.10 255.255.255.0
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 20.20.20.1 255.255.255.0
[R1]interface GigabitEthernet 0/0/2
[R1-GigabitEthernet0/0/2]ip address 30.30.30.1 255.255.255.0
# Configure R2.
[Huawei]system-view
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 172.16.1.10 255.255.255.0
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 20.20.20.10 255.255.255.0
[R2]interface GigabitEthernet 0/0/2
[R2-GigabitEthernet0/0/2]ip address 40.40.40.10 255.255.255.0
# Configure R3.
[Huawei]system-view
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 10.10.10.2 255.255.255.0
[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip address 40.40.40.1 255.255.255.0
[R3]interface GigabitEthernet 0/0/2
[R3-GigabitEthernet0/0/2]ip address 30.30.30.10 255.255.255.0
Create and run an OSPF process on each router. Create an area and enter
the OSPF area view. Specify the interface that runs OSPF and the area to
which the interface belongs.
# Configure R1.
[R1]ospf 1
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 20.20.20.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 30.30.30.0 0.0.0.255
#Configure R2.
[R2]ospf 1
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 20.20.20.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 40.40.40.0 0.0.0.255
# Configure R3.
[R3]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 10.10.10.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 40.40.40.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 30.30.30.0 0.0.0.255
# Configure R1.
[R1]rsa local-key-pair create
The key name will be: Host
% RSA keys defined for Host already exist.
Confirm to replace them? (y/n)[n]:y
The range of public key size is (512 ~ 2048).
NOTES: If the key modulus is greater than 512,
It will take a few minutes.
Input the bits in the modulus[default = 512]:2048
[R1]aaa
[R1-aaa]local-user admin password cipher 123456
[R1-aaa]local-user admin privilege level 3
[R1-aaa]local-user admin service-type ssh
[R1-aaa]stelnet server enable
Info: Succeeded in starting the STELNET server.
[R1]ssh user admin authentication-type password
Copyright © Huawei Technologies Co., Ltd. Page 6
Configuring Automatic Enterprise Network O&M
#Configure R2.
[R2]rsa local-key-pair create
The key name will be: Host
% RSA keys defined for Host already exist.
Confirm to replace them? (y/n)[n]:y
The range of public key size is (512 ~ 2048).
NOTES: If the key modulus is greater than 512,
It will take a few minutes.
Input the bits in the modulus[default = 512]:2048
[R2]aaa
[R2-aaa]local-user admin password cipher 123456
[R2-aaa]local-user admin privilege level 3
[R2-aaa]local-user admin service-type ssh
[R2-aaa]stelnet server enable
Info: Succeeded in starting the STELNET server.
[R2]ssh user admin authentication-type password
Authentication type setted, and will be in effect next time
[R2]user-interface vty 0 4
[R2-ui-vty0-4]authentication-mode aaa
[R2-ui-vty0-4]protocol inbound ssh
#Configure R3.
[R3]rsa local-key-pair create
The key name will be: Host
% RSA keys defined for Host already exist.
Confirm to replace them? (y/n)[n]:y
The range of public key size is (512 ~ 2048).
NOTES: If the key modulus is greater than 512,
It will take a few minutes.
Input the bits in the modulus[default = 512]:2048
[R3]aaa
[R3-aaa]local-user admin password cipher 123456
[R3-aaa]local-user admin privilege level 3
[R3-aaa]local-user admin service-type ssh
[R3-aaa]stelnet server enable
Info: Succeeded in starting the STELNET server.
[R3]ssh user admin authentication-type password
Authentication type setted, and will be in effect next time
[R3]user-interface vty 0 4
[R3-ui-vty0-4]authentication-mode aaa
[R3-ui-vty0-4]protocol inbound ssh
time.sleep(2)
output=command.recv(65535)
print output
## Disconnect the SSH session.
ssh_client.close()
backup.close()
## Disconnect the SSH session.
ssh_client.close()
10.1 Verification
#
interface GigabitEthernet0/0/1
ip address 40.40.40.2 255.255.255.0
#
interface GigabitEthernet0/0/2
ip address 30.30.30.2 255.255.255.0
#
interface NULL0
#
ospf 1
area 0.0.0.0
network 10.10.10.0 0.0.0.255
network 30.30.30.0 0.0.0.255
network 40.40.40.0 0.0.0.255
#
stelnet server enable
#
user-interface con 0
authentication-mode password
set authentication password cipher %$%$v:.
{Vo~Vt;s;grBK&HD9,%S$wJDM)zzk69v.\&X&+%jX%S',%$%$
user-interface vty 0 4
authentication-mode aaa[root@manage backup]#
The preceding output indicates that the R3's configuration is backed up.
12.1 Appendix
Table 12.1.1.1.1.1.1.1.1 IP address planning
Device Interface IP Address
R1 G0/0/0 192.168.1.2/24
R1 G0/0/1 20.20.20.1/24
R1 G0/0/2 30.30.30.1/24
R2 G0/0/0 172.16.1.2/24
R2 G0/0/1 20.20.20.2/24
R2 G0/0/2 40.40.40.1/24
R3 G0/0/0 10.10.10.2/24
R3 G0/0/1 40.40.40.2/24
R3 G0/0/2 30.30.30.2/24
R1 G0/0/1 R2 G0/0/1
R1 G0/0/2 R3 G0/0/2
R2 G0/0/1 R1 G0/0/1
R2 G0/0/2 R3 G0/0/1
R3 G0/0/1 R2 G0/0/2
R3 G0/0/2 R1 G0/0/2