From 9bf9d58c481801f6cfc0a0a17c655a6fd93d846d Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 27 Feb 2019 10:16:59 -0600 Subject: [PATCH] IPAE: DNS lookup provides subnet mask as well as IP If the user types in a name in the IP Address Entry form, also replace the subnet mask. This is particularly useful for pinging, since ping doesn't allow access to the subnet mask field, and if an inappropriate mask is autoIP-entered, then the results might be unexpected. Exception for DHCP ranges: Actually, it shouldn't be necessary (since the IP address field is disabled for DHCP), but just for completeness, I ensure that the second field is not altered for DHCP range entries. Scenario: Level4, Small Subnets 1.) fix router2, so the subnet mask is /30 2.) from pc1, ping pc2 (which is address 192.168.1.3) -lastIP sets subnet mask to 255.255.255.252 -that makes .3 the broadcast address -fix result: lastIP mask is replaced by pc2's real mask. --- EduNetworkBuilder/IPAddressEntry.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/EduNetworkBuilder/IPAddressEntry.cs b/EduNetworkBuilder/IPAddressEntry.cs index a9100cb..b2ded60 100644 --- a/EduNetworkBuilder/IPAddressEntry.cs +++ b/EduNetworkBuilder/IPAddressEntry.cs @@ -249,9 +249,11 @@ namespace EduNetworkBuilder { tIPAddress = mynet.DNSLookup(ParentDevice, tbIPAddress.Text); } - if(tIPAddress != null) + if (tIPAddress != null) //device name used, convert to IP address and netmask { taddress = tIPAddress.GetIP; + if (DHCPInterface == null) + tbNetmask.Text = tIPAddress.GetMaskString; } else taddress = tbIPAddress.Text.ParseIp();