CN106603750A - Method and system for configuring local static network address - Google Patents
Method and system for configuring local static network address Download PDFInfo
- Publication number
- CN106603750A CN106603750A CN201710054649.5A CN201710054649A CN106603750A CN 106603750 A CN106603750 A CN 106603750A CN 201710054649 A CN201710054649 A CN 201710054649A CN 106603750 A CN106603750 A CN 106603750A
- Authority
- CN
- China
- Prior art keywords
- address
- mac address
- equipment
- mac
- network
- 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.)
- Granted
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/50—Address allocation
- H04L61/5038—Address allocation for local use, e.g. in LAN or USB networks, or in a controller area network [CAN]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L61/00—Network arrangements, protocols or services for addressing or naming
- H04L61/50—Address allocation
- H04L61/5092—Address allocation by self-assignment, e.g. picking addresses at random and testing if they are already in use
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L2101/00—Indexing scheme associated with group H04L61/00
- H04L2101/60—Types of network addresses
- H04L2101/618—Details of network addresses
- H04L2101/622—Layer-2 addresses, e.g. medium access control [MAC] addresses
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Small-Scale Networks (AREA)
Abstract
The invention discloses a method for configuring a local static network address, comprising the following steps: S1, acquiring a first IP address, a second IP address, and a first subnet mask address; S2, capturing an LLDP data packet connected by a device to a network, reading link layer data, and acquiring a third IP address, a first MAC address, a second MAC address, and a second subnet mask address; S3, calculating out a fourth IP address according to the third IP address, the first MAC address and the second MAC address; and S4, when a predetermined condition is met, configuring the IP address in the local configuration file of the device as the fourth IP address; or, configuring the IP address in the network card of the device as the first IP address. The method has the following advantages: the method can ensure that the network addresses in the whole network do not conflict or repeat; the method needs no human intervention, and the method is of high efficiency and low cost.
Description
Technical field
The present invention relates to a kind of Ethernet field, more particularly to a kind of local static network address of configuration method and be
System.
Background technology
The network address intelligent configuration method of Ethernet access equipment has various, and presently most popular divides for DHCP dynamics
Method of completing the square, using DHCP method configure be dynamic network address, i.e., have a Dynamic Host Configuration Protocol server in network system, specially
For providing network address distribution service for terminal unit.Its basic process is that terminal access device is taken to the DHCP in network
Business device sends distribution network address request, after DHCP receives request, the network address is sent in the way of replying frame
The equipment, after the equipment receives the Frame for including the network address, extracts the network address, and by local network ground
Location is set to the network address.It is exactly to be configured by manual type in addition, basic skills is corresponding by being manually entered
The manual configuration of the network address is carried out in terminal access device.
But, using DHCP Configuration networks address, must be requested that can only have one in whole network and must have one
Dynamic Host Configuration Protocol server, in other words the same network address can only be distributed by Dynamic Host Configuration Protocol server, and distribute is dynamic network
Address;If Dynamic Host Configuration Protocol server is not present or failure, cannot just distribute the network address, terminal unit cannot use network;And
And DHCP is possible to cause network address collision phenomenon to occur in distribution, it is impossible to accomplish accurate in complete meaning;
Meanwhile, the network address can not be assigned to which the equipment of some position, that is to say, that cannot be direct by the network address
Navigate to the terminal access device.Using manual type, network is carried out for long-range, hidden or large number of terminal unit
Will exist during address configuration take time and effort, high cost, the low shortcoming of efficiency, and very likely because accidentally artificial
Slip up and cause network address collision or other hidden danger.
The content of the invention
The technical problem to be solved in the present invention is that:For the technical problem that prior art is present, the present invention provides one
Plant and can ensure that the network address in whole network does not conflict, do not repeat, it is not necessary to human intervention, efficiency high, the configuration of low cost
The method and system of local static network address.
To solve above-mentioned technical problem, technical scheme proposed by the present invention is:A kind of local static network address of configuration
Method, comprises the steps:
S1. obtain the first IP address:LocalIPAddressFromEthFile, the second IP address:
LocalIPAddressFromNetAdapter, the first subnet mask address:LocalSubnetMask;First IP address
For the IP address in equipment local profile, second IP address is the IP address in the local network interface card of equipment, described first
Subnet mask address is the subnet mask address in equipment local profile;
S2. the LLDP packets in equipment institute access network are captured, link layer data is read, the 3rd IP address is obtained:
EACNIPAddress, the first MAC Address:EACNMacAddress, the second MAC Address:InterfaceMacAddress, second
Subnet mask address:EACNSubnetMask;3rd IP address is the IP address of the switch being connected with the equipment, institute
State the MAC Address that the first MAC Address is the switch, second MAC Address is to connect with the equipment in the switch
The MAC Address of the interface for connecing, the second subnet mask address are the subnet mask address of the switch;
S3. the 4th IP address is calculated according to the 3rd IP address, the first MAC Address and the second MAC Address:
LocalDesignIPAddress;
S4. when first IP address and the 3rd IP address are located at the same network segment, and the 3rd IP address meets default
First condition, when the 4th IP address meets default second condition, by the network interface card of the equipment IP address configure
For the 4th IP address, the IP address in the equipment local profile is configured to into the 4th IP address;Otherwise will be described
IP address in the network interface card of equipment is configured to first IP address.
As a further improvement on the present invention, the concrete steps of step S3 include:
S3.1. IP address alternate field is calculated according to the 3rd IP address, the first MAC Address and the second MAC Address:
LocalIPLastNo;
S3.2. the first character section that the 3rd IP address starts from low level is substituted with the IP address alternate field, obtains the
Four IP address.
As a further improvement on the present invention, the concrete steps of step S3.1 include:Extract the 3rd IP address
The value of the first preset byte, the value of second preset byte of the first MAC Address, the 3rd preset byte of the second MAC Address
Value, by default numerical computational formulas, be calculated the IP address alternate field.
As a further improvement on the present invention, first preset byte is first that the 3rd IP address starts from low level
Byte, second preset byte are the first character section that the first MAC Address starts from low level;3rd preset byte is the
The first character section that two MAC Address start from low level.
As a further improvement on the present invention, the numerical computations refer to started from low level to the 3rd IP address
The first character section that the first character section and the second MAC Address that byte, the first MAC Address start from low level starts from low level
Carry out mathematics plus and minus calculation, and to take the least-significant byte of result of calculation absolute value be the IP address alternate field.
As a further improvement on the present invention, the default first condition the 3rd IP address is from the beginning of low level
The span of the value of second byte is [1,253].
As a further improvement on the present invention, the default second condition the 4th IP address is from the beginning of low level
The span of the value of first character section is [5,250].
As a further improvement on the present invention, in equipment institute access network can not be grabbed in step S2
During LLDP packets, the IP address in the network interface card of the equipment is configured to into first IP address.
As a further improvement on the present invention, also including local MAC Address of Network Card is configured the step of:SA. obtain the 3rd
MAC Address:LocalMacAddressFromEthFile, the 4th MAC Address:LocalMacAddressFromNetAdapter;
3rd MAC Address is the MAC Address of the network interface card in the equipment local profile, and the 4th MAC Address is described
MAC Address in equipment network interface card;
SB. the 5th MAC ground is generated according to first MAC Address, the second MAC Address, the 3rd MAC Address, the 3rd IP address
Location:LocalDesignMacAddress;
SC. when first IP address and the 3rd IP address are located at the same network segment, and the 3rd IP address meets default
First condition, when the 4th IP address meets default second condition, by the network interface card of the equipment MAC Address configure
For the 5th MAC Address, the MAC Address of the network interface card in the equipment local profile is configured to into the 5th MAC Address;It is no
The MAC Address in the network interface card of the equipment is configured to into the 3rd MAC Address then.
As a further improvement on the present invention, the concrete steps of step SB include:Extract first MAC Address
The value of the 5th preset byte of the value of the 4th preset byte and second MAC Address carries out numerical computations, obtains MAC Address and replaces
For field;Second word that 3rd MAC Address starts from low level is substituted with the 6th preset byte of the 3rd IP address
Section, substitutes the first character section that the 3rd MAC Address starts from low level with the MAC Address alternate field, obtains the 5th MAC
Address.
As a further improvement on the present invention, the 4th preset byte is first that the first MAC Address starts from low level
Individual byte, the 5th preset byte is the first character section that second MAC Address starts from low level, the 6th predetermined word
Save second byte started from low level for the 3rd IP address.
As a further improvement on the present invention, in equipment institute access network can not be grabbed in step S2
During LLDP packets, the MAC Address in the network interface card of the equipment is configured to into the 3rd MAC Address.
A kind of system of the local static network address of configuration, including local address acquisition module, network address acquisition module,
Address calculation module and address configuration module;
The local address acquisition module is used for LocalIPAddressFromEthFile, the second IP address:
LocalIPAddressFromNetAdapter, the first subnet mask address:LocalSubnetMask;First IP address
For the IP address in equipment local profile, second IP address is the IP address in the local network interface card of equipment, described first
Subnet mask address is the subnet mask address in equipment local profile;
The network address acquisition module is used to capture the LLDP packets in equipment institute access network, reads the link number of plies
According to the 3rd IP address of acquisition:EACNIPAddress, the first MAC Address:EACNMacAddress, the second MAC Address:
InterfaceMacAddress, the second subnet mask address:EACNSubnetMask;3rd IP address is to set with described
The IP address of the switch of standby connection, first MAC Address is the MAC Address of the switch, and second MAC Address is
The MAC Address of the interface being connected with the equipment in the switch, the second subnet mask address are the switch
Subnet mask address;
The address calculation module is used to capture the LLDP packets in equipment institute access network, reads link layer data,
Obtain the 3rd IP address:EACNIPAddress, the first MAC Address:EACNMacAddress, the second MAC Address:
InterfaceMacAddress;3rd IP address is the IP address of the switch being connected with the equipment, described first
MAC Address is the MAC Address of the switch, second MAC Address be in the switch with connecing that the equipment is connected
The MAC Address of mouth;
The address configuration module is used for when first IP address and the 3rd IP address are located at the same network segment, and described the
Three IP address meet default first condition, when the 4th IP address meets default second condition, by the net of the equipment
IP address in card is configured to the 4th IP address, and the IP address in the equipment local profile is configured to the 4th IP
Address;The IP address in the network interface card of the equipment is configured to into first IP address otherwise.
As a further improvement on the present invention, the address configuration module be additionally operable to when the network address acquisition module not
When can grab the LLDP packets in equipment institute access network, the IP address in the network interface card of the equipment is configured to into institute
State the first IP address.
As a further improvement on the present invention, the local address acquisition module is additionally operable to obtain the 3rd MAC Address:
LocalMacAddressFromEthFile, the 4th MAC Address:LocalMacAddressFromNetAdapter;Described 3rd
MAC Address is the MAC Address of the network interface card in the equipment local profile, and the 4th MAC Address is the equipment network interface card
In MAC Address;
The address calculation module is additionally operable to according to first MAC Address, the second MAC Address, the 3rd MAC Address, the 3rd IP
Address generates the 5th MAC Address:LocalDesignMacAddress;
The address configuration module is additionally operable to be located at the same network segment with the 3rd IP address when first IP address, and described
3rd IP address meets default first condition, when the 4th IP address meets default second condition, by the equipment
MAC Address in network interface card is configured to the 5th MAC Address, by the MAC Address of the network interface card in the equipment local profile
It is configured to the 5th MAC Address;The MAC Address in the network interface card of the equipment is configured to into the 3rd MAC Address otherwise.
As a further improvement on the present invention, the address configuration module be additionally operable to when the network address acquisition module not
When can grab the LLDP packets in equipment institute access network, the MAC Address in the network interface card of the equipment is configured to
3rd MAC Address.
Compared with prior art, it is an advantage of the current invention that:
1st, the present invention does not need human intervention, it is not required that server or address arrange device, you can is automatically performed terminal access and sets
The intelligent static configuration of the standby network address, efficiency high, low cost, accuracy rate are high, it is ensured that the network address in whole network is not
Conflict, do not repeat.
Description of the drawings
Fig. 1 is the schematic flow sheet of specific embodiment of the invention IP address configuration.
Fig. 2 is the schematic flow sheet of specific embodiment of the invention MAC Address configuration.
Specific embodiment
Below in conjunction with Figure of description and concrete preferred embodiment, the invention will be further described, but not therefore and
Limit the scope of the invention.
As shown in figure 1, a kind of method of the local static network address of configuration of the present embodiment, step is:On terminal unit
After electrically activating, the first IP address is obtained:LocalIPAddressFromEthFile, the second IP address:
LocalIPAddressFromNetAdapter, the first subnet mask address:LocalSubnetMask;First IP address is to set
IP address in standby local profile, the second IP address are the IP address in the local network interface card of equipment, the first subnet mask address
For the subnet mask address in equipment local profile;Second IP address is the IP address configured by terminal unit network interface card.
In the present embodiment, terminal unit electricity on local network interface card, can normally after use, in capture apparatus institute access network
LLDP(Link Layer Discovery Protocol, Link Layer Discovery Protocol)Packet, reads link layer data, obtains
Take the 3rd IP address:EACNIPAddress, the first MAC Address:EACNMacAddress, the second MAC Address:
InterfaceMacAddress, the second subnet mask address:EACNSubnetMask;3rd IP address is to be connected with equipment
The IP address of switch, MAC Address of first MAC Address for switch, the second MAC Address are to be connected with equipment in switch
The MAC Address of interface, subnet mask address of the second subnet mask address for switch.
In the present embodiment, step S3 is concretely comprised the following steps:S3.1. according to the 3rd IP address, the first MAC Address and
Two MAC Address calculate IP address alternate field:LocalIPLastNo;S3.2. the 3rd IP ground is substituted with IP address alternate field
The first character section that location starts from low level, obtains the 4th IP address.The concrete steps of step S3.1 include:Extract the 3rd IP address
The value of the first preset byte, the value of first the second preset byte of MAC Address, the value of the 3rd preset byte of the second MAC Address, pass through
Default numerical computational formulas, are calculated IP address alternate field.Certainly, the first preset byte, the second preset byte and
Three preset bytes can also select the bytes different from the present embodiment.
In the present embodiment, the first character section started from low level in the 3rd IP address is extracted, is designated as:IPLastNo.If
3rd IP address is:192.168.111.222, then IPLastNo is 222.Extract that the first MAC Address starts from low level first
Individual byte, is designated as EACNMacLastNo.If the first MAC Address is 11-20-58-F4-72-A1, then EACNMacLastNo is
A1.The first character section started from low level in extracting the second MAC Address, is designated as InterfaceMacLastNo.If the 2nd MAC ground
Location is 23-E2-58-33-22-F5, then InterfaceMacLastNo is F5.
In the present embodiment, IP address alternate field is obtained by following mathematical calculation:LocalIPLastNo.
LocalIPLastNo = IPLastNo + InterfaceMacLastNo – EACNMacLastNo.In the present embodiment,
The value of LocalIPLastNo is(222+ F5- A1)Result of calculation absolute value takes the value of its least-significant byte.Due to 222 be decimal scale
Value, A1 and F5 are the value of 16 systems, therefore, need to be converted into identical system in calculating process, then carry out plus-minus calculating,
Obtain the result of correspondence system.245-161=306 of LocalIPLastNo=222+F5- A1=222+, its binary representation
For 100110010, its least-significant byte is taken for 00110010, decimal value is 50.
In the present embodiment, the first character section that the 3rd IP address starts from low level is substituted with LocalIPLastNo, obtain
4th IP address:LocalDesignIPAddress.In the present embodiment, the 4th IP address LocalDesignIPAddress
For:192.168.111.50.
In the present embodiment, when the first IP address and the 3rd IP address are located at the same network segment, and the 3rd IP address meets pre-
If first condition, when the 4th IP address meets default second condition, the IP address in the network interface card of equipment is configured to into the 4th
IP address in equipment local profile is configured to the 4th IP address by IP address;Otherwise by the IP ground in the network interface card of equipment
Location is configured to the first IP address.In the present embodiment, by the first IP address, the 3rd IP address, and with the first IP address and
3rd IP address distinguishes corresponding first subnet mask address and the second subnet mask address, you can with determine the first IP address and
Whether the 3rd IP address belongs to the same network segment, when the same network segment is belonged to, illustrates that the switch is credible, performs subsequent step, when
When being not belonging to the same network segment, illustrate that the switch is insincere, the first IP address is directly configured to the IP address of equipment network interface card.
In the present embodiment, default first condition is taking for the value of second byte that the 3rd IP address starts from low level
Value scope is [1,253].Default second condition is the value model of the value of the first character section that the 4th IP address starts from low level
Enclose for [5,250].The span and the 4th IP ground of the value of second byte started from low level by the 3rd IP address of regulation
The span of the value of the first character section that location starts from low level is judged, can prevent IP address from occurring abnormal, cause wide
The problems such as broadcasting storm.
In the present embodiment, when terminal unit cannot capture LLDP packets by network, such as network card status exception, or
Person's crawl LLDP packet time-out etc., i.e., cannot be calculated the 4th IP address by above-mentioned step.Directly judge an IP
Whether address is equal to the second IP address, equal to configuration is then terminated, is not equal to, and the IP address in the network interface card of equipment is configured to the
One IP address.
In the present embodiment, for the network interface card of some manufacturer productions, there may not be unique MAC Address.Therefore, make
During with such network interface card, need for the network card configuration MAC Address.In the present embodiment, as shown in Fig. 2 terminal equipment configuration is local
The step of MAC Address of Network Card is:SA. obtain the 3rd MAC Address:LocalMacAddressFromEthFile, the 4th MAC ground
Location:LocalMacAddressFromNetAdapter;MAC ground of 3rd MAC Address for the network interface card in equipment local profile
Location, the 4th MAC Address are the MAC Address in equipment network interface card;SB. according to first MAC Address, the second MAC Address, the 3rd
MAC Address, the 3rd IP address, the 5th MAC Address of generation:LocalDesignMacAddress;SC. when the first IP address
The same network segment is located at the 3rd IP address, and the 3rd IP address meets default first condition, the 4th IP address meets default
During second condition, the MAC Address in the network interface card of equipment is configured to into the 5th MAC Address, by the net in equipment local profile
The MAC Address of card is configured to the 5th MAC Address;The MAC Address in the network interface card of equipment is configured to into the 3rd MAC Address otherwise.
In the present embodiment, the value and second MAC Address of the 4th preset byte of first MAC Address are extracted
The value of the 5th preset byte carries out numerical computations, obtains MAC Address alternate field;With the 6th predetermined word of the 3rd IP address
Section substitutes second byte that the 3rd MAC Address starts from low level, substitutes the described 3rd with the MAC Address alternate field
The first character section that MAC Address starts from low level, obtains the 5th MAC Address.4th preset byte be the first MAC Address from
The first character section that low level starts, the 5th preset byte are the first character section that second MAC Address starts from low level,
6th preset byte is second byte that the 3rd IP address starts from low level.
In the present embodiment, if the first MAC Address is 11-20-58-F4-72-A1, the second MAC Address is 23-E2-58-
33-22-F5, then it is F5-A1=54 that MAC Address replaces field, and F5, A1 and 54 are hexadecimal value, MAC Address replacement word
The value of section is result of calculation and takes absolute value.In the present embodiment, if the 3rd MAC Address is 2A-FA-23-87-5C-B8, the 3rd
IP address is:192.168.111.222, the value of second byte that the 3rd IP address starts from low level is 111, is converted to 16
Enter to be made as 6F.5C in 3rd MAC Address is substituted with 6F, the B8 in the 3rd MAC Address of replacement of field 54 is replaced with MAC Address,
Then the 5th MAC Address is 2A-FA-23-87-6F-54.When the 3rd MAC Address is equal to four MAC Address, by terminal unit
MAC Address in network interface card is configured to the 5th MAC Address, and the MAC Address of the network interface card in terminal unit local profile is configured
For the 5th MAC Address.The MAC Address in the network interface card of terminal unit is configured to into the 3rd MAC Address otherwise.
In the present embodiment, when terminal unit cannot capture LLDP packets by network, such as network card status exception, or
Person's crawl LLDP packet time-out etc., i.e., cannot be calculated the 4th IP address by above-mentioned step.Directly judge the 3rd MAC
Whether address is equal to the 4th MAC Address, equal to configuration is then terminated, does not wait and then configures the MAC Address in the network interface card of terminal unit
For the 3rd MAC Address.
The system of the local static network address of configuration of the present embodiment, including local address acquisition module, the network address obtain
Delivery block, address calculation module and address configuration module;Local address acquisition module is used for
LocalIPAddressFromEthFile, the second IP address:LocalIPAddressFromNetAdapter, the first subnet are covered
Code address:LocalSubnetMask;First IP address is the IP address in equipment local profile, and the second IP address is to set
IP address in standby local network interface card, the first subnet mask address are the subnet mask address in equipment local profile;Network
The LLDP packets that address acquisition module is used in capture apparatus institute access network, read link layer data, obtain the 3rd IP ground
Location:EACNIPAddress, the first MAC Address:EACNMacAddress, the second MAC Address:InterfaceMacAddress,
Second subnet mask address:EACNSubnetMask;3rd IP address is the IP address of the switch being connected with equipment, first
MAC Address of the MAC Address for switch, the MAC Address of interface of second MAC Address to be connected with equipment in switch, second
Subnet mask address of the subnet mask address for switch;The LLDP that address calculation module is used in capture apparatus institute access network
Packet, reads link layer data, obtains the 3rd IP address:EACNIPAddress, the first MAC Address:
EACNMacAddress, the second MAC Address:InterfaceMacAddress;3rd IP address is the switch being connected with equipment
IP address, MAC Address of first MAC Address for switch, the second MAC Address are the interface being connected with equipment in switch
MAC Address;Address configuration module is used to be located at the same network segment when the first IP address and the 3rd IP address, and the 3rd IP address meets
IP address in the network interface card of equipment, when the 4th IP address meets default second condition, is configured to by default first condition
IP address in equipment local profile is configured to the 4th IP address by four IP address;Otherwise by the IP in the network interface card of equipment
Address configuration is the first IP address.
In the present embodiment, address configuration module is additionally operable to be accessed when network address acquisition module can not grab equipment
During LLDP packets in network, the IP address in the network interface card of equipment is configured to into the first IP address.
In the present embodiment, local address acquisition module is additionally operable to obtain the 3rd MAC Address:
LocalMacAddressFromEthFile, the 4th MAC Address:LocalMacAddressFromNetAdapter;3rd MAC
MAC Address of the address for the network interface card in equipment local profile, the 4th MAC Address are the MAC Address in equipment network interface card;Address
Computing module is additionally operable to generate the 5th according to first MAC Address, the second MAC Address, the 3rd MAC Address, the 3rd IP address
MAC Address:LocalDesignMacAddress;Address configuration module is additionally operable to when the first IP address is located at the 3rd IP address
The same network segment, and the 3rd IP address meets default first condition, when the 4th IP address meets default second condition, by equipment
Network interface card in MAC Address be configured to the 5th MAC Address, the MAC Address of the network interface card in equipment local profile is configured to
5th MAC Address;The MAC Address in the network interface card of equipment is configured to into the 3rd MAC Address otherwise.
In the present embodiment, address configuration module is additionally operable to be accessed when network address acquisition module can not grab equipment
During LLDP packets in network, the MAC Address in the network interface card of equipment is configured to into the 3rd MAC Address.
Above-mentioned simply presently preferred embodiments of the present invention, not makees any pro forma restriction to the present invention.Although of the invention
It is disclosed above with preferred embodiment, but it is not limited to the present invention.Therefore, it is every without departing from technical solution of the present invention
Content, according to the technology of the present invention essence to any simple modification made for any of the above embodiments, equivalent variations and modification, all should fall
In the range of technical solution of the present invention protection.
Claims (16)
1. the method for the local static network address of a kind of configuration, it is characterised in that comprise the steps:
S1. obtain the first IP address:LocalIPAddressFromEthFile, the second IP address:
LocalIPAddressFromNetAdapter, the first subnet mask address:LocalSubnetMask;First IP address
For the IP address in equipment local profile, second IP address is the IP address in the local network interface card of equipment, described first
Subnet mask address is the subnet mask address in equipment local profile;
S2. the LLDP packets in equipment institute access network are captured, link layer data is read, the 3rd IP address is obtained:
EACNIPAddress, the first MAC Address:EACNMacAddress, the second MAC Address:InterfaceMacAddress, second
Subnet mask address:EACNSubnetMask;3rd IP address is the IP address of the switch being connected with the equipment, institute
State the MAC Address that the first MAC Address is the switch, second MAC Address is to connect with the equipment in the switch
The MAC Address of the interface for connecing, the second subnet mask address are the subnet mask address of the switch;
S3. the 4th IP address is calculated according to the 3rd IP address, the first MAC Address and the second MAC Address:
LocalDesignIPAddress;
S4. when first IP address and the 3rd IP address are located at the same network segment, and the 3rd IP address meets default
First condition, when the 4th IP address meets default second condition, by the network interface card of the equipment IP address configure
For the 4th IP address, the IP address in the equipment local profile is configured to into the 4th IP address;Otherwise will be described
IP address in the network interface card of equipment is configured to first IP address.
2. the method for the local static network address of configuration according to claim 1, it is characterised in that the tool of step S3
Body step includes:
S3.1. IP address alternate field is calculated according to the 3rd IP address, the first MAC Address and the second MAC Address:
LocalIPLastNo;
S3.2. the first character section that the 3rd IP address starts from low level is substituted with the IP address alternate field, obtains the
Four IP address.
3. the method for the local static network address of configuration according to claim 2, it is characterised in that step S3.1
Concrete steps include:Extract the value of the first preset byte of the 3rd IP address, second preset byte of the first MAC Address
Value, the value of the 3rd preset byte of the second MAC Address, by default numerical computational formulas, are calculated the IP address
Alternate field.
4. the method for the local static network address of configuration according to claim 3, it is characterised in that:First predetermined word
The first character section started from low level for the 3rd IP address is saved, second preset byte is the first MAC Address from the beginning of low level
First character section;3rd preset byte is the first character section that the second MAC Address starts from low level.
5. the method for the local static network address of configuration according to claim 4, it is characterised in that:The numerical computations are
First character section that the first character section that starts from low level to the 3rd IP address of finger, the first MAC Address start from low level and
Second MAC Address carries out mathematics plus and minus calculation from the first character section that low level starts, and takes the least-significant byte of result of calculation absolute value and be
The IP address alternate field.
6. the method for the local static network address of configuration according to claim 5, it is characterised in that:Described default first
It is [1,253] that condition is the span of the value of second byte that the 3rd IP address starts from low level.
7. the method for the local static network address of configuration according to claim 6, it is characterised in that:Described default second
It is [5,250] that condition is the span of the value of the first character section that the 4th IP address starts from low level.
8. the method for the local static network address of configuration according to any one of claim 1 to 7, it is characterised in that:Work as institute
When the LLDP packets in equipment institute access network can not be grabbed in stating step S2, by the IP in the network interface card of the equipment
Address configuration is first IP address.
9. the method for the local static network address of configuration according to any one of claim 2 to 7, it is characterised in that also wrap
The step of including configuration local MAC Address of Network Card:
SA. obtain the 3rd MAC Address:LocalMacAddressFromEthFile, the 4th MAC Address:
LocalMacAddressFromNetAdapter;3rd MAC Address is the network interface card in the equipment local profile
MAC Address, the 4th MAC Address are the MAC Address in the equipment network interface card;
SB. the 5th MAC ground is generated according to first MAC Address, the second MAC Address, the 3rd MAC Address, the 3rd IP address
Location:LocalDesignMacAddress;
SC. when first IP address and the 3rd IP address are located at the same network segment, and the 3rd IP address meets described
Default first condition, when the 4th IP address meets the default second condition, by the MAC in the network interface card of the equipment
Address configuration is the 5th MAC Address, and the MAC Address of the network interface card in the equipment local profile is configured to the 5th
MAC Address;The MAC Address in the network interface card of the equipment is configured to into the 3rd MAC Address otherwise.
10. the method for the local static network address of configuration according to claim 9, it is characterised in that step SB
Concrete steps include:Extract the 4th preset byte of first MAC Address value and second MAC Address the 5th preset
The value of byte carries out numerical computations, obtains MAC Address alternate field;Institute is substituted with the 6th preset byte of the 3rd IP address
Second byte that the 3rd MAC Address starts from low level is stated, the 3rd MAC Address is substituted with the MAC Address alternate field
From the first character section that low level starts, the 5th MAC Address is obtained.
11. methods for configuring local static network address according to claim 10, it is characterised in that the described 4th presets
Byte is the first character section that the first MAC Address starts from low level, and the 5th preset byte is second MAC Address from low
The first character section that position starts, the 6th preset byte is second byte that the 3rd IP address starts from low level.
12. methods for configuring local static network address according to claim 11, it is characterised in that:When step S2
In when can not grab the LLDP packets in equipment institute access network, the MAC Address in the network interface card of the equipment is matched somebody with somebody
It is set to the 3rd MAC Address.
A kind of 13. systems for configuring local static network address, it is characterised in that:Including local address acquisition module, network ground
Location acquisition module, address calculation module and address configuration module;
The local address acquisition module is used for LocalIPAddressFromEthFile, the second IP address:
LocalIPAddressFromNetAdapter, the first subnet mask address:LocalSubnetMask;First IP address
For the IP address in equipment local profile, second IP address is the IP address in the local network interface card of equipment, described first
Subnet mask address is the subnet mask address in equipment local profile;
The network address acquisition module is used to capture the LLDP packets in equipment institute access network, reads the link number of plies
According to the 3rd IP address of acquisition:EACNIPAddress, the first MAC Address:EACNMacAddress, the second MAC Address:
InterfaceMacAddress, the second subnet mask address:EACNSubnetMask;3rd IP address is to set with described
The IP address of the switch of standby connection, first MAC Address is the MAC Address of the switch, and second MAC Address is
The MAC Address of the interface being connected with the equipment in the switch, the second subnet mask address are the switch
Subnet mask address;
The address calculation module is used to capture the LLDP packets in equipment institute access network, reads link layer data,
Obtain the 3rd IP address:EACNIPAddress, the first MAC Address:EACNMacAddress, the second MAC Address:
InterfaceMacAddress;3rd IP address is the IP address of the switch being connected with the equipment, described first
MAC Address is the MAC Address of the switch, second MAC Address be in the switch with connecing that the equipment is connected
The MAC Address of mouth;
The address configuration module is used for when first IP address and the 3rd IP address are located at the same network segment, and described the
Three IP address meet default first condition, when the 4th IP address meets default second condition, by the net of the equipment
IP address in card is configured to the 4th IP address, and the IP address in the equipment local profile is configured to the 4th IP
Address;The IP address in the network interface card of the equipment is configured to into first IP address otherwise.
14. systems for configuring local static network address according to claim 13, it is characterised in that:The address configuration
Module is additionally operable to when the network address acquisition module can not grab the LLDP packets in equipment institute access network,
IP address in the network interface card of the equipment is configured to into first IP address.
15. systems for configuring local static network address according to claim 14, it is characterised in that:
The local address acquisition module is additionally operable to obtain the 3rd MAC Address:LocalMacAddressFromEthFile, the 4th
MAC Address:LocalMacAddressFromNetAdapter;During 3rd MAC Address is the equipment local profile
Network interface card MAC Address, the 4th MAC Address is the MAC Address in the equipment network interface card;
The address calculation module is additionally operable to according to first MAC Address, the second MAC Address, the 3rd MAC Address, the 3rd IP
Address generates the 5th MAC Address:LocalDesignMacAddress;
The address configuration module is additionally operable to be located at the same network segment with the 3rd IP address when first IP address, and described
3rd IP address meets default first condition, when the 4th IP address meets default second condition, by the equipment
MAC Address in network interface card is configured to the 5th MAC Address, by the MAC Address of the network interface card in the equipment local profile
It is configured to the 5th MAC Address;The MAC Address in the network interface card of the equipment is configured to into the 3rd MAC Address otherwise.
16. systems for configuring local static network address according to claim 15, it is characterised in that:The address configuration
Module is additionally operable to when the network address acquisition module can not grab the LLDP packets in equipment institute access network,
MAC Address in the network interface card of the equipment is configured to into the 3rd MAC Address.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710054649.5A CN106603750B (en) | 2017-01-24 | 2017-01-24 | A kind of method and system configuring local static network address |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710054649.5A CN106603750B (en) | 2017-01-24 | 2017-01-24 | A kind of method and system configuring local static network address |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106603750A true CN106603750A (en) | 2017-04-26 |
CN106603750B CN106603750B (en) | 2019-11-12 |
Family
ID=58586153
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710054649.5A Active CN106603750B (en) | 2017-01-24 | 2017-01-24 | A kind of method and system configuring local static network address |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106603750B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102469170A (en) * | 2010-11-03 | 2012-05-23 | 英业达集团(天津)电子技术有限公司 | Method for generating static Internet protocol (IP) address under disk operating system (DOS) |
US20120131197A1 (en) * | 2010-11-23 | 2012-05-24 | Sensormatic Electronics, LLC | Method and apparatus for automatically resolving conflicting devices on a network |
CN103236975A (en) * | 2013-05-09 | 2013-08-07 | 杭州华三通信技术有限公司 | Message forwarding method and message forwarding device |
CN105376347A (en) * | 2015-12-11 | 2016-03-02 | 上海斐讯数据通信技术有限公司 | IP address allocation method and system |
-
2017
- 2017-01-24 CN CN201710054649.5A patent/CN106603750B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102469170A (en) * | 2010-11-03 | 2012-05-23 | 英业达集团(天津)电子技术有限公司 | Method for generating static Internet protocol (IP) address under disk operating system (DOS) |
US20120131197A1 (en) * | 2010-11-23 | 2012-05-24 | Sensormatic Electronics, LLC | Method and apparatus for automatically resolving conflicting devices on a network |
CN103236975A (en) * | 2013-05-09 | 2013-08-07 | 杭州华三通信技术有限公司 | Message forwarding method and message forwarding device |
CN105376347A (en) * | 2015-12-11 | 2016-03-02 | 上海斐讯数据通信技术有限公司 | IP address allocation method and system |
Non-Patent Citations (2)
Title |
---|
庞振源: "一种基于LLDP的链路层拓扑发现系统的开发实现", 《科技视界》 * |
陈凡锋: "批量静态末N位原地址转换技术研究", 《福建电脑》 * |
Also Published As
Publication number | Publication date |
---|---|
CN106603750B (en) | 2019-11-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US5845095A (en) | Method and apparatus for storing and restoring controller configuration information in a data communication system | |
CN104901858A (en) | System communication method based on CAN bus | |
CN105049502B (en) | The method and apparatus that device software updates in a kind of cloud network management system | |
CN106878459A (en) | The intelligent networking gateway implementation method and its equipment of a kind of self adaptation | |
CN108965374B (en) | Integrated monitoring device, integrated monitoring method, and storage medium | |
CN102413044B (en) | Method, device, equipment and system for generating DHCP (Dynamic Host Configuration Protocol) Snooping binding table | |
CN109698871A (en) | A kind of optical fiber distributed type access system and its management method | |
CN105389278B (en) | A kind of slave serial communication method based on CAN bus | |
CN108347351A (en) | Method, device and system for compatibility of dual Ethernet cards of equipment | |
CN107612774A (en) | A kind of multi-channel synchronous sleep method and system | |
CN109617824A (en) | Collecting method, device and server | |
CN101741925A (en) | Method for allocating access addresses and access equipment | |
CN106487575A (en) | A kind of communication module batch upgrading method based on power line communication | |
CN105279073B (en) | Inline system performance test methods and device | |
CN106797329A (en) | Special-purpose terminal and its operating method for measuring the Internet wire quality | |
CN107221939B (en) | The control of reactive power compensating group network system and its capacity diffused integration compensation method | |
CN105939241A (en) | Connection disconnecting method and device | |
CN106603750A (en) | Method and system for configuring local static network address | |
CN107454208A (en) | A kind of is the method that network address is distributed from node device | |
CN102215206A (en) | Method and device for identifying network protocol based on NPTA technology | |
CN115987949A (en) | IP address field conflict detection method and device and electronic equipment | |
CN109733831A (en) | Control the method and device of feeder | |
CN105187497A (en) | Line card management method based on distributed system OLT (Optical Line Terminal) equipment | |
CN110460683B (en) | Method and switching equipment for processing data message through gateway | |
CN107846312A (en) | A kind of network service ensuring equipment |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |