From 2a17fba36c1c0e51af0cb65ac6eea3b21dc62add Mon Sep 17 00:00:00 2001 From: Tim Young Date: Wed, 27 Feb 2019 08:41:58 -0600 Subject: [PATCH] broadcast address only applies to correct subnet Ultimately, the problem stemmed from a ping to an address with the wrong subnet mask (auto-filled subnet) which turned the address (which should have been routed) into a local broadcast. Only the global broadcast, or a local broadcast should be accepted, not a broadcast that should be routed. This can be seen in Level 4, Small Subnets puzzle. 1.) fix router2 to be /31 2.) from pc1, ping pc2 (which turns into 192.168.1.3) -autoIP filled in a subnet mask of 255.255.255.252 -therefore 1.3 is considered the broadcast IP. -result: a local broadcast on the 192.168.2 network. 3.) from pc1, ping 192.168.1.1 or 192.168.1.4 works fine. 4.) edit firewall1, edit route to 192.168.1.1 -make no changes, just hit OK 5.) again from pc1 ping pc2 -now autoIP fills in subnet mask 255.255.255.0 -result: it works --- EduNetworkBuilder/NetworkDevice.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/EduNetworkBuilder/NetworkDevice.cs b/EduNetworkBuilder/NetworkDevice.cs index ef649e3..57d44e5 100644 --- a/EduNetworkBuilder/NetworkDevice.cs +++ b/EduNetworkBuilder/NetworkDevice.cs @@ -1431,7 +1431,12 @@ namespace EduNetworkBuilder public bool HasBroadcastAddress(NB_IPAddress dest) { if (dest.BroadcastAddress == dest.GetIP) return true; - foreach(NetworkCard nic in NICs) + + //This "fixes" a strange fringe case of when we configure a subnet such that + //a packet that is traversing the network suddenly is a broadcast packet on the + //target network. Gotta have odd subnetting for this to happen + if (NB.BroadcastIPString == dest.GetIPString) return true; + foreach (NetworkCard nic in NICs) { if (nic.HasBroadcastAddresses(dest)) return true;