Answer the question
In order to leave comments, you need to log in
How to convert an IP address?
I'm not very versed in network technology and IP addressing. But I often see the following...
For example, how to determine the subnet mask, gateway and the number of machines that "fit" in this range from the entry 10.7.4.0/30 ?
Can you show point by point (step by step) how to find out the properties of the network from such a record (IP address / number)? Gateways, number of cars, etc.
Thanks in advance!
Answer the question
In order to leave comments, you need to log in
https://ru.wikipedia.org/wiki/%D0%9C%D0%B0%D1%81%D...
well, it will also be useful:
https://ru.wikipedia.org/wiki/IP
https: //ru.wikipedia.org/wiki/IPv4
You will not recognize the gateway from this entry, it is indicated separately when setting up the computer.
1. In total, there are 4 bytes in the IP address (each of the 4 digits of the address is 1 byte), this is 32 bits.
2. The last digit in your entry is 30 (this is the length of the subnet mask), indicating that out of 32 bits of the address, the 30 most significant bits are the subnet mask. On your example:
subnet mask: 10.7.4.000000 - I presented the last digit in the binary system (the first ones make no sense, because they are entirely included in the mask).
The subnet mask is the same for all hosts on the subnet. In order for nodes from one network to access nodes on another network, gateways are needed. Gateways either directly have addresses on both subnets or use other intermediate gateways to access networks. This is how the Internet works at the IP level.
3. For addressing hosts on the network, you have 32-30=2 bits. In two bits, 4 values can be represented: 00, 01, 10, 11. In this case, the smaller and larger value is used by the TCP / IP stack for various kinds of multicasts and broadcasts.
Based on the foregoing, only 2 values \u200b\u200bare left for addressing hosts according to your example. Those. there can be 2 hosts on your subnet.
addr = "10.7.4.0/30"
addr1 = addr.split('/')
hostcount = pow(2,32 - int(addr1[1]))
intmask = pow(2,32) - hostcount
dmask = [str((intmask >> (i*8)) & 0xFF) for i in range(0,4)]
dmask.reverse()
mask = ".".join(dmask)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question