"Translated from MoS article" How to calculate the subnet ID of an IP address correctly?

Source: Internet
Author: User

How to calculate the subnet ID of an IP address correctly?

From:
How to calculate the correct subnet for a interface (document ID 1059759.1)

Suitable for:
Oracle database-enterprise edition-version 10.2.0.1 and later
Information in this document applies to any platform.

Goal:
The subnet ID of an IP address is calculated correctly, and the subnet ID is for oifcfg.

Oifcfg requires you to Pulic and Cluster_interconnect's subnet ID.


However, the ifconfig command usually displays the IP address and netmask, and does not display the subnet ID

This article shows you how to calculate the subnet ID.
More generally, it is. This article also applies to questions such as the following: How to determine the subnet ID for a given IP address and netmask?

How to resolve:
In this article, if the NIC name is E1000G0 for the public network. IP address is 171.197.26.137,netmask is ffffffc0

From the output of the ifconfig-a. We will see for example the following:

E1000G0:FLAGS=209040843<UP,BROADCAST,RUNNING,MULTICAST,DEPRECATED,IPV4,NOFAILOVER,COS>MTU Index 2inet 171.197.26.137 netmask ffffffc0 broadcast 171.197.26.191groupname Prodether 0:14:4f:95:39:9a

Note: The above netmask is shown in hexadecimal as ffffffc0 (in some operating system platforms.) will appear in decimal instead of hexadecimal)

The NETMASKFFFFFFC0 = ff.ff.ff.c0=255.255.255.192 binary is 11111111.11111111.11111111.11000000

There is also a commonly used method to denote netmask is a two-digit number, such as "26", the "26". is calculated by, for example, the following:

11111111.11111111.11111111.11000000=> (1+1+1+1+1+1+1+1) + (1+1+1+1+1+1+1+1) + (1+1+1+1+1+1+1+1) + (1+1+0+0+0+0+0+0 ) =8+8+8+2=26

For a given network IP address (171.197.26.137) and netmask (255.255.255.192). The way to calculate the subnet ID at high speed is to use IP calculator
Free IP calculator can be obtained online, in this example, I use the IP calculator is derived from: Http://jodies.de/ipcalc.

Bring the network IP address (171.197.26.137) and netmask (255.255.255.192) into the IP calculator, giving output such as the following:

Result:address:  171.197.26.137       10101011.11000101.00011010.10 001001Netmask:  255.255.255.192 =  11111111.11111111.11111111.11 000000Wildcard:   0.  0.  0.       00000000.00000000.00000000.00 111111=>network:  171.197.26.128/26    10101011.11000101.00011010.10 000000 (Class B) broadcast:171.197. 26.191       10101011.11000101.00011010.10 111111HostMin:  171.197.26.129       10101011.11000101.00011010.10 000001HostMax:  171.197.26.190       10101011.11000101.00011010.10 111110hosts/net:62

= = Pay attention to the "network:171.197." 26.128/26 "
Ignore/26 in the above output. The subnet ID required by OIFCFG is 171.197. 26.128

Another way to get the subnet ID is to do a bit-and operation on each bit of the IP address and netmask:

171.197.26.137 = 10101011.11000101.00011010.10 001001255.255.255.192 = 11111111.11111111.11111111.11 000000                 &------------------------------------                    10101011.11000101.00011010.10 000000 = 171.197.26.128

Of course. Another way to get subnet ID is to use the OIFCFG command itself
Oifcfg iflist command displays the NIC name and the corresponding subnet ID

$./oifcfg ifliste1000g0 171.197.26.128e1000g2 171.197.26.128e1000g3 10.241.6.0

To set the oifcfg of the public network, you need to use syntax such as the following:

Oifcfg Setif-global E1000g0/171.197.26.128:public
Translator Note:
If: Netmask is ffffff00 (that is, 255.255.255.0), then the subnet ID is: the first three parts of the IP address + a 0 form part fourth if: netmask is not ffffff00, then the subnet ID needs to be calculated. The process of calculation is described in the procedure

"Translated from MoS article" How to calculate the subnet ID of an IP address correctly?

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.