欢迎光临
我们一直在努力

How to calculate the correct subnet for an interface (文档 ID 1059759.1)

APPLIES TO:

Oracle Database – Enterprise Edition – Version 10.2.0.1 and later

Information in this document applies to any platform.

GOAL

How to calculate the correct subnet to use in oifcfg, etc.

oifcfg requires you to enter the subnet used for public and cluster_interconnect networks.

However, ifconfig usually shows the IP and the netmask, but not the subnet.

This note will show how to determine the subnet to be used with oifcfg.

More generally, it also applies to the general question of determining the subnet for a given interface, given the IP address and netmask.

SOLUTION

Suppose that the interface to be used for public network is e1000g0 with ip address 171.197.26.137 and netmask ffffffc0.

In ifconfig -a output we will see this:

e1000g0:

flags=209040843

mtu 1500 index 2

inet 171.197.26.137 netmask ffffffc0 broadcast 171.197.26.191

groupname prod

ether 0:14:4f:95:39:9a

Note that the netmask is displayed as ffffffc0 in hex. (In some platforms it is displayed in decimal rather than hex.)

This netmask ffffffc0 = ff.ff.ff.c0 = 255.255.255.192 .

In binary notation this is 11111111.11111111.11111111.11000000

Another common way you may see to represent the netmask is as a simple 2-digit number like “26”, to get this number, simply add up the digits: 

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

A fast way to find the subnet, given the network address (171.197.26.137) and the netmask (255.255.255.192), is to use an IP calculator.

Free IP calculators are available online. In this example, I used the calculator at http://jodies.de/ipcalc. Many others are available.

Plugging the address (171.197.26.137) and the netmask (255.255.255.192) into the calculator at http://jodies.de/ipcalc gives this output:

Result:

Address:  171.197. 26.137       10101011.11000101.00011010.10 001001

Netmask:  255.255.255.192 = 26  11111111.11111111.11111111.11 000000

Wildcard:   0.  0.  0. 63       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 111111

HostMin:  171.197. 26.129       10101011.11000101.00011010.10 000001

HostMax:  171.197. 26.190       10101011.11000101.00011010.10 111110

Hosts/Net: 62

=> note how that gives the network 171.197.26.128/26

Ignore the /26 in this output, the “subnet” needed for oifcfg is 171.197.26.128.

Another way to get this information is to do a bit-AND on each bit of the address and netmask:

171.197. 26.137 => 10101011.11000101.00011010.10 001001

255.255.255.192 => 11111111.11111111.11111111.11 000000

                 & ———————————— 

                   10101011.11000101.00011010.10 000000 => 171.197.26.128

Yet another way to get this information is from oifcfg itself.

The command oifcfg iflist shows the interface name and subnet for each interface:

$ ./oifcfg iflist

e1000g0 171.197.26.128

e1000g2 171.197.26.128

e1000g3 10.241.6.0

So now you see where that 128 is coming from in oifcfg iflist. For each interface, oifcfg iflist shows the subnet for that interface.

So to enter this into oifcfg as the public network, you would use this syntax:

oifcfg setif -global e1000g0/171.197.26.128:public

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。