Analysis on Obtaining valid subnet IP addresses

Source: Internet
Author: User
Tags character classes


I. Requirements: 124.0. [22-25, 28-29,31]. 0/24, 117.123.16.0/22,113.73 .0.0/17 only allow IP parameter transfer in this range 2. Demand Evolution-> you need to find the IP address range: steps for network mask, subnet address, broadcast address, minimum address, and maximum address: 1. take 113.73.0.0/17 as an example. The detailed calculation is as follows: 2. host address: 01101110 01001011 00000000 000000003. network mask: 11111111 11111111 10000000 000000004. subnet address: 01101110 01001011 00000000 00000000 (113.73.0.0) 5. subnet address = Host address and network mask and operation www.2cto.com 6. broadcast address: 01101110 01001011 01111111 11111111 (113.73.127.255) 7. broadcast address = exclusive or operation of subnet address and network mask 8. remove a network address (113.73.0.0) and a broadcast address (113.73.127.255) 9. minimum address: 113.73.0.110. maximum address: 113.73.127.254 3. knowledge points: 1. review of the basic concept of IP Address: IP addresses are expressed in binary. Each IP address is 32 bits in length, and the bits are converted into bytes. The four IP addresses are divided into two parts: the network number and the host number: the number of network numbers directly determines the number of network numbers that can be allocated (calculation method 2 ^ number of network numbers) the number of host numbers determines the maximum number of hosts in the network (calculation method 2 ^ number of host numbers-2). According to the Npower of 2, it is converted to a 10-digit system that is easy to understand. '/17' indicates 11111111.111111.0000000.00000000. This is a subnet mask, also known as a network code. That is, the information available in the subnet mask of 255.255.255.128.0 is 1, indicating a network bit, and 0 indicates a host bit, change the host bit in the subnet mask to 1 to get the broadcast address 3. based on the IP address AND subnet mask, the valid IP address range can be calculated. AND is used for calculation. The core of the operation is: The subnet IP address can be obtained in case of 0, 1, AND 1, the available IP addresses in the subnet are between the subnet IP address and the broadcast address. there is usually a broadcast address and a network address in the IP address. These two addresses are generally unavailable. You can refer to the details www.2cto.com 5. IP address range algorithm: 1) company IP address information query: (for example, 113.73.0.0 or 113.73.0.0/17) Yangge recommends a better method: http://soc.taobao.com:9999/soc/extend/?extend_feature=acl The ACL management tab in the macro-defined query. You can use it later. The valid IP address range (113.73.0.0-113.73.127.255) indicated by 113.73.0.0/17 can be calculated. 2) You can use the subnet mask calculator (IPSubnetter), 3) if none of the above methods are used, manually calculate 6. regular Expressions: 1 )(?: Pattern) matches pattern but does not get the matching result. That is to say, this is a non-get match and is not stored for future use. This is useful when you use the "or" character (|) to combine each part of a pattern. For example, 'industr (?: Y | ies) is a simpler expression than 'industry | industries. 2) ^ matches the start position of the input string. If the Multiline attribute of the RegExp object is set, ^ matches the position after '\ n' or' \ R. 3) Note that regular expressions are judged once by a flag. For example, regular expressions must be written in three sections for regular expression verification, 0-99,100-199,120-127 the specific validation of the three segments of IP addresses is as follows: 4) Note: regular expressions are used in java, and matches requires that the entire string matches the regular expression, find requires a part of the matching expression of the string. Www.2cto.com 5) Java regular escape, if the regular expression is so written pSpecialStr = Pattern. compile ("[A-Za-z0-9 _-.] *"); the execution reports the following error:
Here, the escape problem of regular expressions is involved: "Just escape it. The character class in square brackets is in". "When there are characters on both sides, it indicates the character between one character and the other. The value of the Left character must be smaller than the value of the right character. The cause of this syntax error is that the value of "+" is smaller than the value. You can write as follows :[. a-Za-z0-9 _-] *, like "-" is also the same in normal regular expressions, 15 special significance of metacharacters need to be escaped :( [{}]) \ ^-$ |? * +. The character classes are a little special. Escape: [] ^-\ where "-" is placed on both sides of the character class, that is, placed on the side of the left square brackets and the right square brackets, you do not need to escape.

Author zhoushu126

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.