Windows firewall: allow communication within subnet only

Is there a way to make a rule for windows firewall which will allow a program to communicate within a LAN but not outside the subnet? Basically forbidding internet communication but allowing LAN…

Windows firewall: allow communication within subnet only

Source: [H]ardOCP – Windows firewall: allow communication within subnet only