CN104935684A - Method for automatically configuring IP address - Google Patents
Method for automatically configuring IP address Download PDFInfo
- Publication number
- CN104935684A CN104935684A CN201510390263.2A CN201510390263A CN104935684A CN 104935684 A CN104935684 A CN 104935684A CN 201510390263 A CN201510390263 A CN 201510390263A CN 104935684 A CN104935684 A CN 104935684A
- Authority
- CN
- China
- Prior art keywords
- address
- network
- ethernet
- configuration
- computer
- 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
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/5007—Internet protocol [IP] addresses
- H04L61/5014—Internet protocol [IP] addresses using dynamic host configuration protocol [DHCP] or bootstrap protocol [BOOTP]
Abstract
The invention discloses a method for automatically configuring an IP (Internet Protocol) address. The method comprises the following steps: S1, checking the state of network connection; S2, acquiring the IP address with a DHCP (Dynamic Host Configuration Protocol), and configuring the IP address which is connected with Ethernet as an automatic acquisition way by calling the netshell command of windows; S3, checking whether or not the IP address is correct, ending if the IP address is correct, otherwise, executing S4; and S4, automatically specifying a new IP address. The method has the beneficial effects that the IP address of a new network to which a computer accesses can be acquired automatically. Before address configuration, the state of network equipment is checked. One-click configuration of the IP address is implemented, and the operation time is saved. After the IP address is configured, connectivity testing of a gateway is added in order to ensure the correctness of the IP address. The situation of address conflict and the situation of failure in network connection in automatic configuration are avoided; the efficiency is higher than that of manual IP address configuration; and the configuration success rate is high.
Description
Technical field
The present invention relates to technical field of network information, relate to a kind of method of automatic configuration of IP address.
Background technology
In current technical field of network information, when a new LAN is accessed to computer, IP address can be obtained by automatic or manual mode, but automatic acquisition IP may cause address conflict or could not get on to the Net in address, and manually revise local ip address in actual application, there is following problem: because the computer literacy of computer user of service is different, so there is so many people not possess the technical ability of manual successful configuration of IP address.Be unfamiliar with can cause configuration failure to the state of computer network facility, layoutprocedure is complicated.The situation such as cannot to verify to the correctness of the IP address of manual configuration.
Summary of the invention
The present invention is directed to the defect of prior art, provide a kind of method of automatic configuration of IP address, effectively can solve above-mentioned prior art Problems existing.
In order to realize above goal of the invention, the technical scheme that the present invention takes is as follows:
A method for automatic configuration of IP address, comprises the following steps:
S1: computer access network, checks the state that network connects;
S2: use DHCP to obtain IP address, by calling the netshell order of windows, is set to automatic acquisition mode by the IP address configuration that Ethernet connects;
S3: check that whether IP address is correct, correctly then terminate, incorrect, perform S4;
S4: automatically specify new IP address.
As preferably, the detailed step of described S1 is as follows:
S101: after computer access network, the all-network obtained in current computer connects;
S102: run CMD command window fill order ipconfig/all, obtain the link information that in computer, all-network connects;
S103: call the hardware information that windows api " GetAdaptersInfo " obtains all-network connection device in computer
S104: use each connects in S102 title to find out the hardware information of same names in the hardware information of S103, judges the type of hardware found out whether PCI or USB device, connects then perform S106 if be local ethernet; If do not find any Ethernet to connect, then represent that Ethernet connection now then performs S105 for disabled status;
S105: perform S104 after calling windows api " EnumConnections, INetConnection.Connect " ethernet network state is set to initiate mode;
S106: run the brief information that CMD command window fill order ipconfig obtains all-network in computer, if check, whether the connection status that the Ethernet found in S104 step connects is that connection status has connected, and terminates, if Media State is Media disconnected, performs S107;
S107: exit whole process, and prompting needs insert network cable or check network cable.
As preferably, the detailed step of described S3 is as follows:
S301: run the IP address information that CMD command window fill order ipconfig/all obtains ethernet network connection.
S302: judge whether IP address information is " 169.254 " beginning; If so, then represent the failure of automatic acquisition IP address, perform S4; If not then expression obtains successfully, terminate.
As preferably, the detailed step of described S4 is as follows:
S401: the network segment traveling through all private IP address;
S402: for each class private IP address network segment, completes the application of local ip address by performing CMD order line;
S403: after application success, performs CMD order: PING " destination address ", obtains order and returns results;
S404: check whether return results middle destination address can be communicated with; If be communicated with, represented that the IP address of current configuration is effective, use this IP address, otherwise carry out the trial of the next network segment; Until find available IP address, and this IP address is specified to be this Computer IP address.
As preferably, the described private IP address network segment is divided three classes, and content is as follows:
Category-A: 10.0.0.0-10.255.255.255;
Category-B: 172.16.0.0 – 172.31.255.255;
C class: 192.168.0.0 – 192.168.255.255.
As preferably, CMD order behavior in described S402: netsh interface ip set address name=Ethernet source=static addr=" IP address " mask=" subnet mask " gateway=" IP address gateway " gwmetric=0.
Compared with prior art the invention has the advantages that: can the IP address of new network of automatic acquisition computer access.Before configuration address, can check the state of the network equipment.Realize a key configuration of IP address, save the operating time.After IP address configuration is good, increase the continuity testing to gateway, to guarantee the correctness of IP address.The address conflict situation that present invention, avoiding configuration automatically and the situation that cannot network, higher than manual configuration IP address efficiency again, and it is high to be configured to power.
Accompanying drawing explanation
Fig. 1 is the main flow chart of inventive embodiments.
Embodiment
For making object of the present invention, technical scheme and advantage clearly understand, to develop simultaneously embodiment referring to accompanying drawing, the present invention is described in further details.
As shown in Figure 1, a kind of method of automatic configuration of IP address, comprises the following steps:
S1: computer access network, checks the state that network connects;
S2: use DHCP to obtain IP address, by calling the netshell order of windows, is set to automatic acquisition mode by the IP address configuration that Ethernet connects;
S3: check that whether IP address is correct, correctly then terminate, incorrect, perform S4;
S4: automatically specify new IP address.
The detailed step of described S1 is as follows:
S101: after computer access network, the all-network obtained in current computer connects;
S102: run CMD command window fill order ipconfig/all, obtain the link information that in computer, all-network connects;
S103: call the hardware information that windows api " GetAdaptersInfo " obtains all-network connection device in computer
S104: use each connects in S102 title to find out the hardware information of same names in the hardware information of S103, judges the type of hardware found out whether PCI or USB device, connects then perform S106 if be local ethernet; If do not find any Ethernet to connect, then represent that Ethernet connection now then performs S105 for disabled status;
S105: perform S104 after calling windows api " EnumConnections, INetConnection.Connect " ethernet network state is set to initiate mode;
S106: run the brief information that CMD command window fill order ipconfig obtains all-network in computer, if check, whether the connection status that the Ethernet found in S104 step connects is that connection status has connected, and terminates, if Media State is Media disconnected, performs S107;
Brief information example is as follows:
Ethernet adapter Connection Name:
Media State...........:Media disconnected
Connection-specific DNS Suffix.:
Description...........:Intel(R)82577LM Gigabit Network Connection
Physical Address.........:F0-DE-F1-1B-39-28
DHCP Enabled...........:Yes
Autoconfiguration Enabled....:Yes
S107: exit whole process, and prompting needs insert network cable or check network cable.
The detailed step of described S3 is as follows:
S301: run the IP address information that CMD command window fill order ipconfig/all obtains ethernet network connection.Examples of information is as follows:
Ethernet Adaptation Unit Ethernet:
Connect specific DNS suffix ....:
Describe ... ... ...: Realtek PCIe GBE Family Controller
Physical address ... ... .:BC-EE-7B-E3-02-8C
DHCP enables ... ... ..: be
Automatic configuration is enabled ... ....: be
Local links IPv6 address ... ..:fe80::8c3e:b8cb:578a:a32%12 (first-selection)
IPv4 address ... ...: 192.168.0.53 (first-selection)
Subnet mask ... ...: 255.255.255.0
Obtain the time of lease ... ...: 2015-06-0219:21:37
The time that lease is expired ... ...: 2015-06-049:44:22
Default gateway ... ... .:192.168.0.1
Dynamic Host Configuration Protocol server ... ... ..:192.168.0.1
DHCPv6IAID...........:264040059
Dns server ... ... ..:192.168.0.1
NetBIOS....... on TCPIP: enable
S302: judge whether IP address information is " 169.254 " beginning; If so, then represent the failure of automatic acquisition IP address, perform S4; If not then expression obtains successfully, terminate.
The detailed step of described S4 is as follows:
S401: the network segment traveling through all private IP address;
The described private IP address network segment is divided three classes, and content is as follows:
Category-A: 10.0.0.0-10.255.255.255;
Category-B: 172.16.0.0 – 172.31.255.255;
C class: 192.168.0.0 – 192.168.255.255.
S402: for each class private IP address network segment, completes the application of local ip address by performing CMD order line;
Described order behavior: netsh interface ip set address name=Ethernet source=staticaddr=" IP address " mask=" subnet mask " gateway=" IP address gateway " gwmetric=0;
S403: after application success, performs CMD order: PING " destination address ", obtains order and returns results;
S404: check whether return results middle destination address can be communicated with; If be communicated with, represented that the IP address of current configuration is effective, use this IP address, otherwise carry out the trial of the next network segment; Until find available IP address, and this IP address is specified to be this Computer IP address.
For a better understanding of the present invention, below S4 is illustrated:
For the Class C IP address network segment in S4, complete the application of local ip address by performing CMD order line:
The IP address gateway arranging computer is: 192.168.0.1;
The IP address arranging computer is: 192.168.0.250;
The subnet mask arranging computer is: 255.255.255.0;
Order behavior: netsh interface ip set address name=Ethernet source=staticaddr=192.168.0.250mask=255.255.255.0gateway=192.168.0.1gwmetric=0;
After application success, perform CMD order: ping 192.168.0.1, obtain order and return results;
Whether inspection returns results middle destination address and can be communicated with; If be communicated with, represented that the IP address of current configuration is effective, use this IP address, otherwise carry out the trial of next network segment 192.168.1.1; Until find available IP address, and this IP address is specified to be this Computer IP address.
Those of ordinary skill in the art will appreciate that, embodiment described here is to help reader understanding's implementation method of the present invention, should be understood to that protection scope of the present invention is not limited to so special statement and embodiment.Those of ordinary skill in the art can make various other various concrete distortion and combination of not departing from essence of the present invention according to these technology enlightenment disclosed by the invention, and these distortion and combination are still in protection scope of the present invention.
Claims (6)
1. a method for automatic configuration of IP address, comprises the following steps:
S1: computer access network, checks the state that network connects;
S2: use DHCP to obtain IP address, by calling the netshell order of windows, is set to automatic acquisition mode by the IP address configuration that Ethernet connects;
S3: check that whether IP address is correct, correctly then terminate, incorrect, perform S4;
S4: automatically specify new IP address.
2. the method for a kind of automatic configuration of IP address according to claim 1, is characterized in that the detailed step of described S1 is as follows:
S101: after computer access network, the all-network obtained in current computer connects;
S102: run CMD command window fill order ipconfig/all, obtain the link information that in computer, all-network connects;
S103: call the hardware information that windows api " GetAdaptersInfo " obtains all-network connection device in computer;
S104: use each connects in S102 title to find out the hardware information of same names in the hardware information of S103, judges the type of hardware found out whether PCI or USB device, connects then perform S106 if be local ethernet; If do not find any Ethernet to connect, then represent that Ethernet connection now then performs S105 for disabled status;
S105: perform S104 after calling windows api " EnumConnections, INetConnection.Connect " ethernet network state is set to initiate mode;
S106: run the brief information that CMD command window fill order ipconfig obtains all-network in computer, if check, whether the connection status that the Ethernet found in S104 step connects is that connection status has connected, and terminates, if Media State is Media disconnected, performs S107;
S107: exit whole process, and prompting needs insert network cable or check network cable.
3., according to the method for a kind of automatic configuration of IP address of claim 1 or 2, it is characterized in that the detailed step of described S3 is as follows:
S301: run the IP address information that CMD command window fill order ipconfig/all obtains ethernet network connection;
S302: judge whether IP address information is " 169.254 " beginning; If so, then represent the failure of automatic acquisition IP address, perform S4; If not then expression obtains successfully, terminate.
4. the method for a kind of automatic configuration of IP address according to claim 1, is characterized in that the detailed step of described S4 is as follows:
S401: the network segment traveling through all private IP address;
S402: for each class private IP address network segment, completes the application of local ip address by performing CMD order line;
S403: after application success, performs CMD order: PING " destination address ", obtains order and returns results;
S404: check whether return results middle destination address can be communicated with; If be communicated with, represented that the IP address of current configuration is effective, use this IP address, otherwise carry out the trial of the next network segment; Until find available IP address, and this IP address is specified to be this Computer IP address.
5. the method for a kind of automatic configuration of IP address according to claim 4, is characterized in that: in described S401, the private IP address network segment is divided three classes, and content is as follows:
Category-A: 10.0.0.0-10.255.255.255;
Category-B: 172.16.0.0 – 172.31.255.255;
C class: 192.168.0.0 – 192.168.255.255.
6. according to the method for a kind of automatic configuration of IP address of claim 4 or 5, it is characterized in that: CMD order behavior in described S402: netsh interface ip set address name=Ethernet source=staticaddr=" IP address " mask=" subnet mask " gateway=" IP address gateway " gwmetric=0.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510390263.2A CN104935684A (en) | 2015-06-30 | 2015-06-30 | Method for automatically configuring IP address |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510390263.2A CN104935684A (en) | 2015-06-30 | 2015-06-30 | Method for automatically configuring IP address |
Publications (1)
Publication Number | Publication Date |
---|---|
CN104935684A true CN104935684A (en) | 2015-09-23 |
Family
ID=54122648
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510390263.2A Pending CN104935684A (en) | 2015-06-30 | 2015-06-30 | Method for automatically configuring IP address |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104935684A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105744012A (en) * | 2016-03-09 | 2016-07-06 | 上海斐讯数据通信技术有限公司 | Automatic solving method and device for IP (Internet Protocol) network segment conflicts of multiple WAN (wide area network) and LAN (local area network) |
CN107592209A (en) * | 2016-07-08 | 2018-01-16 | 北京奇虎科技有限公司 | A kind of multi-network card server automatically configures the method and system of IP address information |
CN108712513A (en) * | 2018-03-27 | 2018-10-26 | 广东欧珀移动通信有限公司 | network address setting method, device, terminal device and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020198881A1 (en) * | 2001-06-26 | 2002-12-26 | International Business Machines Corporation | Method and system for recovering DHCP data |
CN102123181A (en) * | 2010-12-09 | 2011-07-13 | 广东高新兴通信股份有限公司 | Method for automatically configuring IP address to network device |
CN103237093A (en) * | 2013-04-17 | 2013-08-07 | 厦门亿联网络技术股份有限公司 | Self-adaptive IP (internet protocol) address acquiring method |
CN103281203A (en) * | 2013-05-22 | 2013-09-04 | 上海斐讯数据通信技术有限公司 | Ecos (Embedded Configurable Operating System) system-based DHCP (Dynamic Host Configuration Protocol) address assignment management method |
-
2015
- 2015-06-30 CN CN201510390263.2A patent/CN104935684A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020198881A1 (en) * | 2001-06-26 | 2002-12-26 | International Business Machines Corporation | Method and system for recovering DHCP data |
CN102123181A (en) * | 2010-12-09 | 2011-07-13 | 广东高新兴通信股份有限公司 | Method for automatically configuring IP address to network device |
CN103237093A (en) * | 2013-04-17 | 2013-08-07 | 厦门亿联网络技术股份有限公司 | Self-adaptive IP (internet protocol) address acquiring method |
CN103281203A (en) * | 2013-05-22 | 2013-09-04 | 上海斐讯数据通信技术有限公司 | Ecos (Embedded Configurable Operating System) system-based DHCP (Dynamic Host Configuration Protocol) address assignment management method |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105744012A (en) * | 2016-03-09 | 2016-07-06 | 上海斐讯数据通信技术有限公司 | Automatic solving method and device for IP (Internet Protocol) network segment conflicts of multiple WAN (wide area network) and LAN (local area network) |
CN107592209A (en) * | 2016-07-08 | 2018-01-16 | 北京奇虎科技有限公司 | A kind of multi-network card server automatically configures the method and system of IP address information |
CN107592209B (en) * | 2016-07-08 | 2021-04-02 | 北京奇虎科技有限公司 | Method and system for automatically configuring IP address information by multi-network card server |
CN108712513A (en) * | 2018-03-27 | 2018-10-26 | 广东欧珀移动通信有限公司 | network address setting method, device, terminal device and storage medium |
CN108712513B (en) * | 2018-03-27 | 2021-09-17 | Oppo广东移动通信有限公司 | Network address setting method and device, terminal equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10122679B2 (en) | Method, relay agent, and system for acquiring internet protocol address in network | |
EP2928161A1 (en) | Method and apparatus for message transmission | |
CN102984288B (en) | A kind of method and system of automatic management IPv6 address conflicts | |
JP4765796B2 (en) | Router device | |
US8432833B2 (en) | Auto MEP ID assignment within CFM maintenance association | |
CN108449236B (en) | Router function test system | |
CN104935684A (en) | Method for automatically configuring IP address | |
CN104065534A (en) | Test system and test method for router blacklist adding by mobile terminal | |
CN107528747B (en) | Method and device for diagnosing communication state of master station and slave station and computer readable storage medium | |
CN104782105B (en) | For restoring method, data routing means and the medium of the routing iinformation lost | |
CN102244689B (en) | Method and equipment for obtaining remote IP address | |
CN111740908A (en) | Communication method and related equipment | |
CN106304166B (en) | System and method for testing number of concurrent users of wireless router | |
CN107017998B (en) | Method and system for implementing CGN flexible backup | |
CN106302845A (en) | The Domain Name System addresses collocation method of data channel product and device | |
CN102130884A (en) | System and method for negotiating configuration of Internet protocol version 6 (IPv6) network parameters | |
CN111541797A (en) | Eco-based IPV6 implementation method | |
TW201511505A (en) | Automatic test system for IPv6 CE standard | |
CN103002064A (en) | Method, user node and remote access server for releasing address | |
CN107070688B (en) | Method for configuring node and node | |
CN102523313B (en) | Identification method of data bypass and apparatus thereof | |
CN102299860B (en) | Acquisition method and equipment for path maximum transmission unit (Pathmtu) | |
EP2858415B1 (en) | Multi-link-based data transmission method and device | |
CN104468696A (en) | Method, server and device for performing point-to-point connection | |
CN107547668A (en) | Message processing method and device, Dynamic Host Configuration Protocol server |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information | ||
CB02 | Change of applicant information |
Address after: 641000 Sichuan province Neijiang City Songshan Road No. 183 Applicant after: SICHUAN XLY INFORMATION SAFETY TECHNOLOGY CO., LTD. Address before: 641000 Sichuan province Neijiang City Songshan Road No. 183 Applicant before: Sichuan SalvationData Information Safety Technology Co., Ltd. |
|
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20150923 |