CN114866515A - IP address configuration method, device, electronic equipment and storage medium - Google Patents

IP address configuration method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114866515A
CN114866515A CN202210425420.9A CN202210425420A CN114866515A CN 114866515 A CN114866515 A CN 114866515A CN 202210425420 A CN202210425420 A CN 202210425420A CN 114866515 A CN114866515 A CN 114866515A
Authority
CN
China
Prior art keywords
address
dynamic
server
static
switch
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210425420.9A
Other languages
Chinese (zh)
Inventor
李果
田艳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Unisinsight Technology Co Ltd
Original Assignee
Chongqing Unisinsight Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing Unisinsight Technology Co Ltd filed Critical Chongqing Unisinsight Technology Co Ltd
Priority to CN202210425420.9A priority Critical patent/CN114866515A/en
Publication of CN114866515A publication Critical patent/CN114866515A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0631Management of faults, events, alarms or notifications using root cause analysis; using analysis of correlation between notifications, alarms or events based on decision criteria, e.g. hierarchy, tree or time analysis
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0876Aspects of the degree of configuration automation
    • H04L41/0886Fully automatic configuration

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Automation & Control Theory (AREA)
  • Small-Scale Networks (AREA)

Abstract

The embodiment of the invention provides an IP address configuration method, an IP address configuration device, electronic equipment and a storage medium, and relates to the technical field of servers. Firstly, according to a configuration file, starting a dynamic host configuration protocol function of the switch so that the switch allocates a dynamic IP address for each server according to static IP address information and a static IP address type; then, determining all target servers which have obtained dynamic IP addresses, and obtaining the dynamic IP address of each target server; and finally, establishing communication with each target server respectively according to each dynamic IP address, and converting the dynamic IP address of each target server into a static IP address to complete IP address configuration. In this way, each server communicating with the switch is allocated with a dynamic IP address through the dynamic host configuration protocol function on the switch, and the dynamic IP address is converted into a static IP address, so that the static IP addresses are automatically configured for the servers in batches.

Description

IP address configuration method, device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of servers, in particular to an IP address configuration method, an IP address configuration device, electronic equipment and a storage medium.
Background
With the development of internet technology, data is growing in an explosive amount, large-scale data centers are becoming more and more popular, and the number of servers is increasing.
In the process of debugging the servers, an operating system needs to be deployed and a static IP address needs to be configured for each server, so that the servers can meet the use requirements of users.
In the prior art, after the deployment of the operating systems of the servers is completed, a static IP address is manually configured for each server usually in a manual manner, and this method is not only inefficient, but also prone to errors.
Disclosure of Invention
The invention aims to provide an IP address configuration method, an IP address configuration device, an electronic device and a storage medium, which can allocate a dynamic IP address to each server communicating with a switch through a dynamic host configuration protocol function on the switch and convert the dynamic IP address into a static IP address, thereby realizing automatic configuration of the static IP address for batch servers.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, an embodiment of the present invention provides an IP address configuration method, which is applied to an electronic device, where the electronic device communicates with a switch, and the switch further communicates with at least one server; the electronic equipment stores a configuration file in advance, wherein the configuration file comprises static IP address information and static IP address types planned in advance; the method comprises the following steps:
according to the configuration file, starting a dynamic host configuration protocol function of the switch, so that the switch allocates a dynamic IP address for each server according to the static IP address information and the static IP address type;
starting from the import time of the configuration file, detecting whether each server obtains the dynamic IP address according to a set time interval, and stopping detection after a set time length is reached;
determining all target servers which have obtained the dynamic IP addresses, and obtaining the dynamic IP address of each target server;
and establishing communication with each target server respectively according to each dynamic IP address, and converting the dynamic IP address of each target server into a static IP address to complete IP address configuration.
In a possible embodiment, the configuration file further includes a MAC address of each of the servers and an IP address of the electronic device;
the switch allocates a dynamic IP address to each server according to the static IP address type and the static IP address information, including:
when the type of the static IP address is a fixed IP address and the static IP address information comprises a preset IP address of each server, the switch binds the preset IP address of each server with the MAC address to complete the allocation of the dynamic IP address of each server;
and when the type of the static IP address is a random IP address and the IP address information is a preset IP network segment, the switch randomly allocates a dynamic IP address to each server from the preset IP network segment to complete the allocation of the dynamic IP address of each server, wherein the dynamic IP address is any one IP address except the IP address of the electronic equipment in the preset IP network segment.
In a possible implementation manner, the step of obtaining the dynamic IP address of each target server includes:
sending a registration instruction to each target server, wherein the registration instruction is used for indicating the target server to return registration information, and the registration information comprises the identification of the target server and the dynamic IP address;
generating a registration configuration file of each target server according to the registration information, wherein the registration configuration file comprises an identifier of the target server, the dynamic IP address of the target server and the IP address type;
and acquiring the dynamic IP address of each target server from the registration configuration file of each target server.
In one possible embodiment, each of the servers maintains a network profile including an IP address type of the server;
the step of converting the dynamic IP address of each target server into a static IP address includes:
and modifying the IP address type in the network configuration file maintained by each target server into a static type from a dynamic type so as to convert the dynamic IP address of each target server into a static IP address.
In one possible embodiment, after the step of converting the dynamic IP address of each of the target servers into a static IP address, the method further comprises:
calculating a difference value between the current time and the importing time of the configuration file;
comparing the difference with the preset time length, wherein the preset time length is greater than the standard total time length of all the servers for completing the IP address configuration;
and when the difference value is greater than the preset time length, closing the dynamic host configuration protocol function of the switch.
In one possible embodiment, after the step of shutting down the dhcp function of the switch, the method further comprises:
detecting the state of an interface corresponding to each server on the switch, wherein the interface is used for realizing communication between the switch and the server;
and if at least one interface state is a closed state, displaying an alarm prompt to prompt a user that the IP address configuration of the server corresponding to the interface fails, wherein the alarm prompt comprises an identifier of each interface with the closed state.
In a possible implementation manner, the electronic device further stores a boot file of an operating system, a storage address of the boot file, and an IP address of the electronic device in advance, and the configuration file further includes the storage address and the IP address of the electronic device;
after the step of opening the dhcp function of the switch according to the configuration file, the method further includes:
and according to the configuration file, carrying out deployment configuration on the switch, so that when the switch receives a deployment request sent by the server, the switch sends the IP address and the storage address of the electronic equipment to the server, so that the server acquires the boot file from the electronic equipment and completes the deployment of the operating system according to the boot file.
In a second aspect, an embodiment of the present invention further provides an IP address configuration apparatus, which is applied to an electronic device, where the electronic device communicates with a switch, and the switch further communicates with at least one server; the electronic equipment stores a configuration file in advance, wherein the configuration file comprises static IP address information and static IP address types planned in advance; the device comprises:
the configuration module is used for starting a dynamic host configuration protocol function of the switch according to the configuration file so that the switch allocates a dynamic IP address to each server according to the static IP address information and the static IP address type;
the detection module is used for detecting whether each server obtains the dynamic IP address or not from the import time of the configuration file according to a set time interval and stopping detection after a set time length is reached;
the acquisition module is used for determining all target servers which acquire the dynamic IP addresses and acquiring the dynamic IP address of each target server;
and the communication module is used for establishing communication with each target server respectively according to each dynamic IP address and converting the dynamic IP address of each target server into a static IP address so as to complete IP address configuration.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a memory for storing one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the IP address configuration method described above.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the IP address configuration method described above.
Compared with the prior art, the IP address configuration method, the IP address configuration device, the electronic device, and the storage medium provided in the embodiments of the present invention first start a dynamic host configuration protocol function of the switch according to the configuration file, so that the switch allocates a dynamic IP address to each server according to the static IP address information and the static IP address type; then, detecting whether each server obtains a dynamic IP address, determining all target servers which obtain the dynamic IP addresses, and obtaining the dynamic IP address of each target server; and finally, establishing communication with each target server respectively according to each dynamic IP address, and converting the dynamic IP address of each target server into a static IP address to complete IP address configuration. The dynamic IP address is distributed to each server communicated with the switch through the dynamic host configuration protocol function on the switch, and the dynamic IP address is converted into the static IP address, so that the static IP address is automatically configured for the batch servers.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is a schematic view of an application scenario of the IP address configuration method according to the embodiment of the present invention.
Fig. 2 is a block diagram of an electronic device according to an embodiment of the present invention.
Fig. 3 is a flowchart illustrating a method for configuring an IP address according to an embodiment of the present invention.
Fig. 4 is a flowchart illustrating another IP address configuration method according to an embodiment of the present invention.
Fig. 5 is a flowchart illustrating a method for configuring an IP address according to another embodiment of the present invention.
Fig. 6 is a block diagram illustrating an IP address configuration apparatus according to an embodiment of the present invention.
Icon: 100-an electronic device; 101-a memory; 102-a processor; 103-a bus; 200-IP address configuration means; 201-configuration module; 202-a detection module; 203-an obtaining module; 204-a communication module; 205-shutdown module; 206-alarm module.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, as presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
Furthermore, the appearances of the terms "first," "second," and the like, if any, are used solely to distinguish one from another and are not to be construed as indicating or implying relative importance.
It should be noted that the features of the embodiments of the present invention may be combined with each other without conflict.
In the prior art, the deployment of an operating system and the configuration of a static IP Address (network Protocol Address) are generally performed on a server in a manual manner, but this manner is not only inefficient but also prone to errors.
With the development of network technology, technicians may perform batch automatic deployment on servers through a PXE (Preboot eXecution Environment) network, but after the deployment of an operating system is completed, a static IP address of the server still needs to be manually configured, or a Dynamic IP address is directly allocated through a DHCP (Dynamic Host Configuration Protocol) server for use.
With the manual configuration, it is not only inefficient but also prone to errors. For the way of allocating the dynamic IP address through the DHCP server, because the dynamic IP address has time limitation, the dynamic IP address of the allocated dynamic IP address may change after the server is restarted, so that other servers cannot establish communication with the server through the original dynamic IP address any more, the dynamic IP address needs to be reallocated, and the operation is not simple enough.
In view of the above problems, the present embodiment provides an IP address configuration method, which allocates a dynamic IP address to each server communicating with a switch through a dynamic host configuration protocol function on the switch, and converts the dynamic IP address into a static IP address, thereby achieving an effect of automatically configuring static IP addresses for servers in batches, improving configuration efficiency, and providing high reliability of the configured static IP addresses.
Referring to fig. 1, fig. 1 is a diagram illustrating an application scenario of the IP address configuration method provided in this embodiment, where the application scenario includes an electronic device 100, a switch and n servers, and the switch is respectively in communication with the electronic device 100 and the n servers.
The servers 1-n may be servers having data storage and processing functions, each of which is installed with a network card supporting PXE (Preboot eXecution Environment), and each network card has a unique MAC Address (Media Access Control Address) for uniquely identifying the server. The motherboard of the server supports network booting, the server is automatically started through the PXE network card after being started, and a required File is downloaded from the electronic device 100 through a TFTP (Trivial File Transfer Protocol) Protocol to perform automatic installation of the operating system. In addition, in order to establish communication with other devices, when servers are debugged, an IP address needs to be allocated to each server, and the IP addresses of the servers are different.
A switch is a network device for forwarding electrical (optical) signals that provides an exclusive electrical signal path for any two network nodes that access the switch. The switch may be an ethernet switch or a fabric switch, etc.
The electronic device 100 is used to deploy an operating system and configure an IP address for the servers 1-n. The electronic device 100 also has a corresponding IP address, and in order to implement communication with the server, the electronic device 100 may pre-program a static IP address of the server 1-the server n, which is generally a fixed IP address in the same network segment or a random IP address in the same network segment, and the IP address of the electronic device is generally set to be in the same network segment as the pre-programmed static IP address.
Referring to fig. 2, fig. 2 is a block diagram illustrating an electronic device 100 according to the present embodiment, where the electronic device 100 may be, but is not limited to, a tablet computer, a notebook computer, a server or other electronic devices with processing capability, and may also be a general-purpose computer or a special-purpose computer. Electronic device 100 includes memory 101, processor 102, and bus 103. The memory 101 and the processor 102 are connected by a bus 103, such as a disk, ROM, or RAM, or any combination thereof. Illustratively, the computer platform may also include program instructions stored in ROM, RAM, or other types of non-transitory storage media, or any combination thereof. The method of the present invention can be implemented according to these program instructions.
The memory 101 is used for storing programs such as an IP address configuration apparatus 200. The IP address configuration device 200 includes at least one software functional module which can be stored in the memory 101 in the form of software or firmware (firmware), and the processor 102 executes the program to implement the IP address configuration device method in the embodiment after receiving the execution instruction.
The Memory 101 may be, but is not limited to, a Random Access Memory (RAM), a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Read Only Memory (EPROM), an electrically Erasable Read Only Memory (EEPROM), and the like.
The processor 102 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the IP address configuration apparatus method in this embodiment may be implemented by integrated logic circuits of hardware in the processor 102 or instructions in the form of software. The processor 102 may be a general-purpose processor, and includes a Central Processing Unit (CPU), a Micro Control Unit (MCU), a Complex Programmable Logic Device (CPLD), a Field Programmable Gate Array (FPGA), and an embedded ARM.
For ease of illustration, only one processor is depicted in electronic device 100. However, it should be noted that the electronic device 100 in the present invention may also comprise a plurality of processors, and thus the steps performed by one processor described in the present invention may also be performed by a plurality of processors in combination or individually. For example, if the processor of the electronic device 100 executes steps a and B, it should be understood that steps a and B may also be executed by two different processors together or separately in one processor. For example, a first processor performs step a and a second processor performs step B, or the first processor and the second processor perform steps a and B together.
On the basis of the above, the IP address configuration apparatus method provided in this embodiment is described. The method is applied to the electronic device 100, and the electronic device 100 stores a configuration file in advance, wherein the configuration file comprises pre-planned static IP address information and static IP address types. Referring to fig. 3, fig. 3 is a flowchart illustrating a method for configuring an IP address configuration apparatus according to the present embodiment, where the method includes steps S110 to S140.
S110, according to the configuration file, starting a dynamic host configuration protocol function of the switch, so that the switch allocates a dynamic IP address for each server according to the static IP address information and the static IP address type.
In this embodiment, the configuration file is generated according to pre-planned configuration information. The configuration information comprises pre-planned static IP address information and static IP address types, wherein the static IP address types are fixed types or random types, if the static IP address types are fixed types, the static IP address information is a fixed IP address of each server in a pre-planned network segment, and if the static IP address types are random types, the static IP address information is the pre-planned network segment.
In addition, the configuration information further includes an MAC address of a Network card of each server, a port number of each server in communication with the switch, an IP address of the electronic device 100 (belonging to the same Network segment as the pre-planned static IP address information), a port number of the electronic device in communication with the switch, a VLAN ID (Virtual Local Area Network ID), an IP address of a VLAN if (Virtual Local Area Network Interface), and a subnet mask (belonging to the same Network segment as the pre-planned static IP address).
After the planning of the configuration information is completed, a configuration file may be generated and imported into the electronic device 100.
For example, the electronic device 100 configures IP addresses for the server 1 and the server 2 through a switch, and the configuration information includes: the MAC address of the network card of the server 1 is 74:3a:20:23: ab: d2, the corresponding switch port is Ten-gigabit Ethernet 2/0/1, the static IP address information is 10.210.146.2, the MAC address of the network card of the server 2 is 30:80:9b:8e: e1: d5, the port number of the corresponding switch is Ten-gigabit Ethernet 2/0/2, the static IP address information is 10.210.146.3, the IP address of the electronic device 100 is 10.210.146.18, the port number of the corresponding switch is Ten-gigabit Ethernet2/0/30, the vlan ID is 100, the IP address of the vlan if is 10.210.146.1, the mask is 255.255.255.255.0, and the static IP address type is fixed. The configuration file generated is as follows:
Figure BDA0003608310100000101
Figure BDA0003608310100000111
after the switch starts the DHCP function, the switch can be used as a DHCP server to distribute dynamic IP addresses for the server. Dynamic IP addresses refer to IP addresses that are obtained by a server as IP addresses with a time limit, which addresses can be assigned for use by other servers when the time expires or the server relinquishes the IP address.
And S120, starting from the import time of the configuration file, detecting whether each server obtains the dynamic IP address or not according to a set time interval, and stopping detection after a set time length is reached.
In this embodiment, the set time interval may be 5 seconds, and since the number of servers is likely to be large, the switch cannot complete the allocation of the dynamic IP addresses at the same time, therefore, from the time of importing the configuration file, every 5 seconds, it is detected whether each server obtains a dynamic IP address, and the detection is stopped after the set time length, and the set time length may be set to 1 hour.
After the switch allocates a dynamic IP address to each server, the switch feeds back the allocated dynamic IP address to the electronic device 100, and the electronic device 100 may detect whether the dynamic IP address responds or not by using a network diagnostic tool ping (packet Internet groper), so as to detect whether the server corresponding to the dynamic IP address obtains the dynamic IP address or not.
S130, determining all target servers which have acquired the dynamic IP addresses, and acquiring the dynamic IP address of each target server.
S140, according to each dynamic IP address, communication is respectively established with each target server, and the dynamic IP address of each target server is converted into a static IP address, so that IP address configuration is completed.
In this embodiment, the static IP address has no time limitation with respect to the dynamic IP address, and other servers or other electronic devices can establish stable communication through the static IP address.
Compared with the prior art, the IP address configuration method provided in this embodiment allocates a dynamic IP address to each server communicating with the switch through a dynamic host configuration protocol function on the switch, and converts the dynamic IP address into a static IP address, thereby achieving a technical effect of automatically configuring the static IP addresses for the servers in batches.
Optionally, in practical application, the switch may allocate a dynamic IP address to the server according to a situation of the remaining available IP addresses. If the residual available IP addresses are less, a fixed IP address can be selected from the IP network segment as a dynamic IP address of the server, and if the residual available IP addresses are more, the IP network segment can be planned and the IP addresses are randomly distributed in the IP network segment as the dynamic IP address of the server.
Thus, the switch may assign a dynamic IP address to each server separately as follows:
and when the type of the static IP address is a fixed IP address and the static IP address information comprises the preset IP address of each server, the switch binds the preset IP address and the MAC address of each server to complete the distribution of the dynamic IP address of each server.
And when the static IP address type is a random IP address and the IP address information is a preset IP network segment, the switch randomly allocates a dynamic IP address to each server from the preset IP network segment to complete the allocation of the dynamic IP address of each server, wherein the dynamic IP address is any one of the IP addresses except the IP address of the electronic equipment in the preset IP network segment.
In this embodiment, the electronic device may perform DHCP configuration on the switch to start a DHCP function of the switch, and enable the switch to allocate a dynamic IP address to each server.
The DHCP configuration for the switch is also different according to different static IP address types. For example, when the static IP address type is a fixed IP address, the DHCP configuration may be as follows:
1) enabling global DHCP functions
Execute system-view into system view
Execute DHCP enable, open DHCP function
2) Creating VLANs
vlan vlan-id
3) Adding an interface where a server and an electronic device are located to a vlan
Port interface-type interface-number
4) Entering a VLANIF interface view
interface vlanif vlan-id
5) Configuring VLANIF interface IP address
ip address ip-address{mask|mask-length}
6) Allocating preset IP address to server by configuration
dhcp server static-bind ip-address ip-address mac-address mac-address
7) DHCP server function with interface address pool for opening interface
dhcp select interface
When the static IP address type is a random IP address, the DHCP configuration may be as follows:
1) enabling global DHCP functions
Execute system-view into system view
Execute DHCP enable, open DHCP function
2) Creating VLANs
vlan vlan-id
3) Adding an interface where a server and an electronic device are located to a vlan
Port interface-type interface-number
4) Entering a VLANIF interface view
interface vlanif vlan-id
5) Configuration VLANIF interface IP address (the default IP network segment to which the interface belongs is the interface address pool)
ip address ip-address{mask|mask-length}
6) Specifying IP addresses in a configured address pool that do not participate in automatic assignment (i.e., IP addresses of electronic devices)
dhcp server excluded-ip-address start-ip-address[end-ip-address]
7) DHCP server function with interface address pool for opening interface
dhcp select interface
Optionally, in addition to completing the IP address configuration of the server, the electronic device 100 may also automatically complete the deployment of the operating system of each server.
Therefore, the electronic device 100 also stores in advance a boot file of the operating system, a storage address of the boot file, and an IP address of the electronic device, and the configuration file further includes the storage address and the IP address of the electronic device. Referring to fig. 4, after step S110, the following step S111 may be further included.
S111, according to the configuration file, deployment configuration is carried out on the switch, so that when the switch receives a deployment request sent by the server, the IP address and the storage address of the electronic equipment are sent to the server, the server obtains the boot file from the electronic equipment, and deployment of the operating system is completed according to the boot file.
In this embodiment, the electronic device 100 needs to store the boot file of the operating system and the storage address of the boot file in advance, which can be implemented in the following manner.
Firstly, downloading an original ISO image of a required operating system (taking centros as an example) and a PXE network card starting file pxelinux.0 to a virtual machine, mounting the image to a local directory/media of the virtual machine, then installing a tool for manufacturing an issuing version, creating a manufacturing directory/ISO, synchronizing all files under the directory/media to the manufacturing directory/ISO, modifying an isolinux.cfg file under the manufacturing directory, adding and executing an automatic installation configuration file to realize automatic installation, modifying an automatic installation configuration file ks.cfg to set a network card configuration to dhcp, and setting to execute a custom script after the system is installed, wherein the custom script is used for receiving and replying a registration instruction sent by electronic equipment to complete registration and manufacturing an ISO image and an MD5 value of the image and the image.
Then, the electronic device 100 configures the IP address (i.e., the IP address of the electronic device 100 in the configuration file), and creates the following directory under any partition with sufficient storage space:
D:\PXE
d \ PXE \ ISO (for storing all contents extracted from installation mirror image)
D \ PXE \ install (for storing the content required by PXE boot)
D \\ PXE \ install \ pxelinux.cfg (for storing PXE boot files)
And then decompressing the prepared image File, copying the decompressed whole content to D: \ PXE \ ISO decompressed catalog isolinux.cfg under isolinux and renaming as default, copying the decompressed vmlinux, initrd.img and vesalenu.c32 files under D: \ PXE \ install, copying the downloaded pxlinux.0 files under D: \ PXE \ install, and finally respectively providing TFTP (TriviFiler Protocol) service and HTTP (HyperText Transfer Protocol) service through TFTP64 and HFS tools.
The electronic device 100 may configure the deployment of the switch according to the configuration file in the following manner.
Option66, Option67 parameters (Option66 specifies server-allocated TFTP server addresses, Option67 specifies server-allocated boot filenames)
dhcp server option66 IP-address TFTP server IP address (i.e. electronic equipment IP address)
The dhcp server option67 ascii boot file absolute path (i.e. D: \ PXE \ install \ pxelinux.0)
After the switch completes the DHCP configuration and the deployment configuration, the server is powered on and started from the PXE network card, and downloads a required File from the electronic device 100 through a TFTP Protocol (simple File Transfer Protocol) to install the operating system.
Optionally, since the server only determines the target server that has obtained the dynamic IP address, but does not know the corresponding relationship between the dynamic IP address and the target server, after determining all target servers that have obtained the dynamic IP address, the server may register each server to perform information management on the server, and obtain the dynamic IP address of each target server.
The electronic device 100 may acquire the dynamic IP address of each target server in the following manner.
And sending a registration instruction to each target server, wherein the registration instruction is used for indicating the target servers to return registration information, and the registration information comprises the identification and the dynamic IP address of the target servers.
And generating a registration configuration file of each target server according to the registration information, wherein the registration configuration file comprises the identification of the target server, the dynamic IP address and the IP address type of the target server.
And acquiring the dynamic IP address of each target server from the registration configuration file of each target server.
In this embodiment, the registration information may further include a server identifier of each target server, a MAC address of the network card, and a dynamic IP address. The electronic device 100 generates a registration configuration file for each target server after receiving the registration information, and records that the IP address type is a dynamic type. The registration configuration file format is as follows:
[SERVER1]
IP=10.210.146.2
IPType=dynamic
MAC=74:3a:20:23:ab:d2
SerialNum=210235A2PDH20A000005
and obtaining the dynamic IP address of each target server by searching the registration configuration file of each target server.
Optionally, each server maintains a network profile, and the network profile includes an IP address type of the server. The electronic device 100 converts the dynamic IP address of each destination server into a static IP address in the following manner.
And modifying the IP address type in the network configuration file maintained by each target server into a static type from a dynamic type so as to convert the dynamic IP address of each target server into a static IP address.
In this embodiment, after the dynamic IP address of the target server is converted into the static IP address, the network is restarted, and the IP address type in the registration configuration file of the target server is modified to the static type.
The above IP address configuration process is implemented on the premise of starting the DHCP function of the switch, and therefore, after the IP address configuration is completed, the DHCP function of the switch needs to be closed.
Therefore, referring to fig. 5 on the basis of fig. 4, after step S140, steps S141-S143 are also included.
S141, calculating a difference between the current time and the import time of the configuration file.
And S142, comparing the difference with a preset time length, wherein the preset time length is greater than the standard total time length for all the servers to complete the IP address configuration.
In this embodiment, the standard total duration for all servers to complete the IP address configuration refers to the total duration for all servers to normally install and configure, and the preset duration may be twice the standard total duration for all servers to complete the IP address configuration.
And S143, when the difference is larger than the preset time length, closing the Dynamic Host Configuration Protocol (DHCP) function of the switch.
In this embodiment, the configuration related to the switch shutdown DHCP function may be as follows:
1) shutting down global DHCP function
Execute system-view into system view
Execute undo DHCP enable, close DHCP function
2) Cancelling VLAN
undo vlan vlan-id
When the exchanger distributes the dynamic IP address for each server, not every server can successfully obtain the dynamic IP address due to the factors of poor network quality and the like, and the server which does not successfully obtain the dynamic IP address can be subjected to alarm prompt so as to facilitate the user to carry out investigation.
Therefore, with continued reference to FIG. 5, following step S143, the following steps S144-S145 may also be included.
S144, detecting the state of the interface where each server is located on the switch, wherein the interface is used for realizing communication between the switch and the server.
S145, if the state of at least one interface is closed, displaying an alarm prompt to prompt that the IP address configuration of the server corresponding to the user interface fails, wherein the alarm prompt comprises the identifier of each interface with the closed state.
In this embodiment, if the state of each interface is an UP state, the electronic device 100 displays that the configuration is successful, and if at least one interface is a DOWN state, an alarm prompt is displayed.
Compared with the prior art, the embodiment has the following beneficial effects:
first, the IP address configuration method provided in this embodiment allocates a dynamic IP address to each server communicating with the switch through a dynamic host configuration protocol function on the switch, and converts the dynamic IP address into a static IP address, thereby achieving a technical effect of automatically configuring a static IP address for the batch servers.
Then, the IP address configuration method provided in this embodiment may select to allocate a fixed IP address to the server as a dynamic IP address according to an actual situation or randomly allocate a dynamic IP address in a certain network segment, so that the flexibility is higher.
Referring to fig. 6, fig. 6 is a block diagram illustrating an IP address configuration apparatus 200 according to the present embodiment. The IP address configuration apparatus 200 is applied to the electronic device 100, and includes: a configuration module 201, a detection module 202, an acquisition module 203, a communication module 204, a shutdown module 205, and an alert module 206.
The configuration module 201 is configured to open a dynamic host configuration protocol function of the switch according to the configuration file, so that the switch allocates a dynamic IP address to each server according to the static IP address information and the static IP address type.
The detecting module 202 is configured to detect whether each server obtains a dynamic IP address according to a set time interval from the time of importing the configuration file, and stop detecting after a set time period is reached.
The obtaining module 203 is configured to determine all target servers that have obtained dynamic IP addresses, and obtain a dynamic IP address of each target server.
The communication module 204 is configured to establish communication with each target server according to each dynamic IP address, and convert the dynamic IP address of each target server into a static IP address to complete IP address configuration.
Optionally, the obtaining module 203 is further configured to:
sending a registration instruction to each target server, wherein the registration instruction is used for indicating the target servers to return registration information, and the registration information comprises the identification and the dynamic IP address of the target servers;
generating a registration configuration file of each target server according to the registration information, wherein the registration configuration file comprises an identifier of the target server, a dynamic IP address and an IP address type of the target server;
and acquiring the dynamic IP address of each target server from the registration configuration file of each target server.
Optionally, each server maintains a network profile, and the network profile includes an IP address type of the server.
The communication module 204 is further configured to:
and modifying the IP address type in the network configuration file maintained by each target server into a static type from a dynamic type so as to convert the dynamic IP address of each target server into a static IP address.
Optionally, the closing module 205 is configured to:
calculating a difference value between the current time and the importing time of the configuration file;
comparing the difference with a preset time length, wherein the preset time length is greater than the standard total time length for all the servers to complete the IP address configuration;
and when the difference value is greater than the preset time length, closing the dynamic host configuration protocol function of the switch.
Optionally, the alarm module 206 is configured to:
detecting the state of each port of the switch, wherein the ports are used for realizing communication between the switch and the server;
and if the state of at least one port is a closed state, displaying an alarm prompt to prompt that the IP address configuration of the server corresponding to the user port fails, wherein the alarm prompt comprises the identifier of each port with the closed state.
It will be apparent to those skilled in the art that the above-described specific operation of the IP address configuration apparatus 200 is provided for convenience and brevity of description. Reference may be made to the corresponding process in the foregoing method embodiment, which is not described herein again.
The embodiment also provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by the processor 102 to implement the IP address configuration method disclosed in the above embodiment.
To sum up, according to the IP address configuration method, apparatus, electronic device, and storage medium provided in the embodiments of the present invention, first, according to a configuration file, a dynamic host configuration protocol function of a switch is started, so that the switch allocates a dynamic IP address to each server according to static IP address information and a static IP address type; then, detecting whether each server obtains a dynamic IP address, determining all target servers which obtain the dynamic IP addresses, and obtaining the dynamic IP address of each target server; and finally, establishing communication with each target server respectively according to each dynamic IP address, and converting the dynamic IP address of each target server into a static IP address to complete IP address configuration. The dynamic IP address is distributed to each server communicated with the switch through the dynamic host configuration protocol function on the switch, and the dynamic IP address is converted into the static IP address, so that the static IP address is automatically configured for the batch servers.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

Claims (10)

1. An IP address configuration method is applied to electronic equipment, the electronic equipment is communicated with a switch, and the switch is also communicated with at least one server; the electronic equipment stores a configuration file in advance, wherein the configuration file comprises static IP address information and static IP address types planned in advance; the method comprises the following steps:
according to the configuration file, starting a dynamic host configuration protocol function of the switch, so that the switch allocates a dynamic IP address for each server according to the static IP address information and the static IP address type;
starting from the import time of the configuration file, detecting whether each server obtains the dynamic IP address according to a set time interval, and stopping detection after a set time length is reached;
determining all target servers which have obtained the dynamic IP addresses, and obtaining the dynamic IP address of each target server;
and establishing communication with each target server respectively according to each dynamic IP address, and converting the dynamic IP address of each target server into a static IP address to complete IP address configuration.
2. The method of claim 1, wherein the configuration file further comprises a MAC address of each of the servers and an IP address of the electronic device;
the switch allocates a dynamic IP address to each server according to the static IP address information and the static IP address type, including:
when the type of the static IP address is a fixed IP address and the static IP address information comprises a preset IP address of each server, the switch binds the preset IP address of each server with the MAC address to complete the allocation of the dynamic IP address of each server;
and when the type of the static IP address is a random IP address and the IP address information is a preset IP network segment, the switch randomly allocates a dynamic IP address to each server from the preset IP network segment to complete the allocation of the dynamic IP address of each server, wherein the dynamic IP address is any one IP address except the IP address of the electronic equipment in the preset IP network segment.
3. The method of claim 1, wherein the step of obtaining the dynamic IP address of each of the target servers comprises:
sending a registration instruction to each target server, wherein the registration instruction is used for indicating the target server to return registration information, and the registration information comprises the identification of the target server and the dynamic IP address;
generating a registration configuration file of each target server according to the registration information, wherein the registration configuration file comprises an identifier of the target server, the dynamic IP address of the target server and the IP address type;
and acquiring the dynamic IP address of each target server from the registration configuration file of each target server.
4. The method of claim 1, wherein each of the servers maintains a network profile, the network profile including an IP address type of the server;
the step of converting the dynamic IP address of each target server into a static IP address includes:
and modifying the IP address type in the network configuration file maintained by each target server into a static type from a dynamic type so as to convert the dynamic IP address of each target server into a static IP address.
5. The method of claim 1, wherein after the step of converting the dynamic IP address of each of the target servers to a static IP address, the method further comprises:
calculating a difference value between the current time and the importing time of the configuration file;
comparing the difference with a preset time length, wherein the preset time length is greater than the standard total time length for all the servers to complete the IP address configuration;
and when the difference value is greater than the preset time length, closing the dynamic host configuration protocol function of the switch.
6. The method of claim 5, wherein after the step of shutting down the dynamic host configuration protocol function of the switch, the method further comprises:
detecting the state of an interface corresponding to each server on the switch, wherein the interface is used for realizing communication between the switch and the server;
and if at least one interface state is a closed state, displaying an alarm prompt to prompt a user that the IP address configuration of the server corresponding to the interface fails, wherein the alarm prompt comprises an identifier of each interface with the closed state.
7. The method according to claim 1, wherein the electronic device further stores a boot file of an operating system, a storage address of the boot file, and an IP address of the electronic device in advance, and the configuration file further includes the storage address and the IP address of the electronic device;
after the step of opening the dhcp function of the switch according to the configuration file, the method further includes:
and according to the configuration file, carrying out deployment configuration on the switch, so that when the switch receives a deployment request sent by the server, the switch sends the IP address and the storage address of the electronic equipment to the server, so that the server acquires the boot file from the electronic equipment and completes the deployment of the operating system according to the boot file.
8. An IP address configuration device is applied to electronic equipment, the electronic equipment is communicated with a switch, and the switch is also communicated with at least one server; the electronic equipment stores a configuration file in advance, wherein the configuration file comprises static IP address information and static IP address types planned in advance; the device comprises:
the configuration module is used for starting a dynamic host configuration protocol function of the switch according to the configuration file so that the switch allocates a dynamic IP address to each server according to the static IP address information and the static IP address type;
the detection module is used for detecting whether each server obtains the dynamic IP address or not from the import time of the configuration file according to a set time interval and stopping detection after a set time length is reached;
the acquisition module is used for determining all target servers which acquire the dynamic IP addresses and acquiring the dynamic IP address of each target server;
and the communication module is used for establishing communication with each target server respectively according to each dynamic IP address and converting the dynamic IP address of each target server into a static IP address so as to complete IP address configuration.
9. An electronic device, characterized in that the electronic device comprises:
one or more processors;
memory to store one or more programs that, when executed by the one or more processors, cause the one or more processors to implement the IP address configuration method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the IP address configuration method according to any one of claims 1 to 7.
CN202210425420.9A 2022-04-21 2022-04-21 IP address configuration method, device, electronic equipment and storage medium Pending CN114866515A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210425420.9A CN114866515A (en) 2022-04-21 2022-04-21 IP address configuration method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210425420.9A CN114866515A (en) 2022-04-21 2022-04-21 IP address configuration method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114866515A true CN114866515A (en) 2022-08-05

Family

ID=82633306

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210425420.9A Pending CN114866515A (en) 2022-04-21 2022-04-21 IP address configuration method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114866515A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115499489A (en) * 2022-11-16 2022-12-20 苏州浪潮智能科技有限公司 Method, device, equipment and readable medium for managing sub-network in link
CN115589397A (en) * 2022-10-25 2023-01-10 毕诗章 Dynamic address allocation method for solidifying host IP through switch interface number

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101184099A (en) * 2007-12-14 2008-05-21 中兴通讯股份有限公司 Second IP address assignment method based on dynamic host machine configuration protocol access authentication
CN106131245A (en) * 2016-08-31 2016-11-16 迈普通信技术股份有限公司 The collocation method of a kind of AP, configuration service device, AP and system
CN106534395A (en) * 2016-11-08 2017-03-22 西安云雀软件有限公司 Method for realizing locking of terminal MAC address and IP address through controlled DHCP mechanism
CN107229492A (en) * 2017-05-17 2017-10-03 东软集团股份有限公司 Installation method, device, system, storage medium and the equipment of server system
CN108810192A (en) * 2018-07-20 2018-11-13 郑州云海信息技术有限公司 A kind of static IP configuration method, device, equipment and readable storage medium storing program for executing
CN113268256A (en) * 2021-06-09 2021-08-17 中国建设银行股份有限公司 Batch installation method and device, server and computer storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101184099A (en) * 2007-12-14 2008-05-21 中兴通讯股份有限公司 Second IP address assignment method based on dynamic host machine configuration protocol access authentication
CN106131245A (en) * 2016-08-31 2016-11-16 迈普通信技术股份有限公司 The collocation method of a kind of AP, configuration service device, AP and system
CN106534395A (en) * 2016-11-08 2017-03-22 西安云雀软件有限公司 Method for realizing locking of terminal MAC address and IP address through controlled DHCP mechanism
CN107229492A (en) * 2017-05-17 2017-10-03 东软集团股份有限公司 Installation method, device, system, storage medium and the equipment of server system
CN108810192A (en) * 2018-07-20 2018-11-13 郑州云海信息技术有限公司 A kind of static IP configuration method, device, equipment and readable storage medium storing program for executing
CN113268256A (en) * 2021-06-09 2021-08-17 中国建设银行股份有限公司 Batch installation method and device, server and computer storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115589397A (en) * 2022-10-25 2023-01-10 毕诗章 Dynamic address allocation method for solidifying host IP through switch interface number
CN115499489A (en) * 2022-11-16 2022-12-20 苏州浪潮智能科技有限公司 Method, device, equipment and readable medium for managing sub-network in link
CN115499489B (en) * 2022-11-16 2023-02-28 苏州浪潮智能科技有限公司 Method, device, equipment and readable medium for managing sub-network in link
WO2024103716A1 (en) * 2022-11-16 2024-05-23 苏州元脑智能科技有限公司 Method and apparatus for managing subnets in link, and device and readable medium

Similar Documents

Publication Publication Date Title
CN108206847B (en) CDN management system, method and device
CN114866515A (en) IP address configuration method, device, electronic equipment and storage medium
US10884759B2 (en) Remote deployment of operating systems
CN106549789B (en) Method and system for realizing server installation
CN109587005B (en) Connection detection method and device, computer equipment and readable storage medium
US10630637B2 (en) Method for ascertaining an IP address and a MAC address of a unit under test mounted in a rack server
CN112328262A (en) Deployment method, system and device of operating system and electronic equipment
CN109039518B (en) The ntp server address intelligent management of Android television system
CN109445801A (en) A kind of method and apparatus detecting bare machine network interface card information
CN105141449A (en) Addition method and device for monitoring configuration
CN106657444A (en) Method and device for configuring IP address of BMC
CN112272246A (en) Out-of-band network IP automatic configuration method and device, electronic equipment and storage medium
CN115061885A (en) Complete machine aging automatic test method and device, electronic equipment and storage medium
CN110971689B (en) System installation method, device, system, equipment and storage medium
CN104158859A (en) PXE-based information acquisition method, PXE (pre-boot execution environment) client, PXE server and system
CN111355708A (en) Equipment password resetting method and device
CN113849228A (en) Operating system batch deployment method, system, terminal and storage medium
CN106452860B (en) Equipment deployment method and device
CN111078305A (en) Information acquisition method and device, server and information management system
CN111367735B (en) Test method and system based on server to be tested and Wuban diagram operating system
CN112099902A (en) Network adapter configuration method and device of virtual machine, electronic device and storage medium
CN115333933B (en) Automatic management method, medium and equipment for servers on machine room
CN111277463B (en) Method, system, terminal and storage medium for testing accuracy of gateway address acquisition by BMC
CN112291096B (en) Configuration method and device of bare metal server
CN113347287B (en) Host discovery and addition method, device, equipment and medium in data center

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination