get subnet mask and gateway from IP address

Deadly 提交于 2019-12-10 10:46:15

问题


How can i calculate subnet mask and gateway from an IP address?

Suppose my IP address is 180.12.24.68

Then how can i calculate this IP's subnet mask and gateway?


回答1:


You cannot calculate your subnet mask or gateway from just an IP address.

You can calculate the range that a potential gateway could be in given an IP address and a netmask. But, the range is basically ((My LAN segment Size) - MyIP). Generally this will be around 253 IP addresses unless you're on a large network.

Given a gateway and a netmask you can calculate a range of potential IP addresses you can configure yourself to use - but if you're manually configuring then you have the chance of clobbering an existing IP address. (This is why DHCP is good)

Given a gateway and an IP address you can calculate enough of your netmask that you can get your traffic to be routed - but depending on the subnet configuration you may not be able to talk to other machines that are on the same LAN segment. An example of this would be if your gateway is 10.1.3.254 and you configure your netmask as 255.255.255.0. The gateway (and the LAN) could actually be masked as 255.255.254.0 (basically, 2 class Cs worth of addresses in a contiguous segment).. So, you'd be able to get to the internet, but you might not be able to talk with 'local machines'.

In summation these are the possible outcomes:

  • mask + gateway = guessable but non-definitive IP address
  • mask + ip = guessable but non-definitive range of IP addresses you might find a gateway
  • ip + gateway = guessable but potentially misconfigured netmask


来源:https://stackoverflow.com/questions/10101520/get-subnet-mask-and-gateway-from-ip-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!