I have some .Net core microservices which I am currently running with dotnet xyz.dll.

They currently run and work fine however in order for one to talk to the other I of course need firewall exceptions.

Without thinking much I used a script to use netsh and add exceptions to the dll. However this appears to not work as intended.

Since dotnet is a compiler and the dll itself is very likely not "running" this is probably way more complicated from a technical sense than it sounds.

Adding exceptions to the dotnet.exe itself sounds like a bad idea so is the only solution to compile to exe and then add exceptions to that?

Just to add a little more background in case it is needed.

I have a series of microservices which are deployed through nomad. Nomad itself copies from a file store, puts it on the machine, then runs the script below. The program runs and everything works except the firewall.

I would of course deploy an exe however then I would have to compile all variants and know the placement target through nomad in order to pick the correct one.

netsh advfirewall firewall add rule name="Allow %1" dir=in action=allow program="%2"
dotnet %2
netsh advfirewall firewall delete rule name="Allow %1" dir=in

(netsh obviously only works on windows however those 2 lines could be conditional on environment)

Cross posted at dotnet core github which may be a better place.

0 Answers