"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, this article also applies to the following questions: How to determine the subnet ID for a given IP address and netmask?

Solution:
This article assumes that the NIC name for the public network is E1000G0,IP address is 171.197.26.137,netmask is ffffffc0

From the output of the ifconfig-a, we will see 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 displayed in hexadecimal as ffffffc0 (in some operating system platforms, it is displayed in decimal instead of hexadecimal)

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

Another common method used to denote netmask is a two-bit number, such as "26", which is calculated as follows:

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), a quick way to calculate the subnet ID is to use IP calculator
Free IP calculator can be obtained online, in this example, the IP calculator I use 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 the following output:

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 "
Ignoring the/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, the other 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 the following syntax:

Oifcfg Setif-global E1000g0/171.197.26.128:public

"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.