Opening firewall for a Windows Service
I've a C# service app that needs to be accessed externally by xml-rpc clients. It's self hosted via HttpListenerRequest; not IIS hosted. (Can't require that servers be IIS enabled)
It works fine from a client when the server开发者_Go百科 firewall is turned off OR the ports the app uses are opened. However if I create a firewall exception to enable the app via its name; its not reachable from the client pc. (I've tried both manually enabling the service and adding code to enable the app from my installer.)
The reason why I want the application enabled; rather than the ports is that the ports may change. (My app will check a range for available ports on the off chance the default ports are in use). From looking around it appears that any service that isn't fully 'self-hosted' cannot be firewall enabled.
Does anyone know a workaround for this?
not sure of the syntax, but I think you have to use netsh with something like this :
netsh http add urlacl url=http://www.contoso.com:80/MyUri user=DOMAINE\utilisateur listen=yes
Try setting SID type to unrestricted
for your service.
Create an Inbound Program or Service Rule
Although the command also permits the value of NONE, that setting means the service cannot be used in a firewall rule as described here. By default, most services in Windows are configured as UNRESTRICTED. If you change the SID type to RESTRICTED, the service might fail to start. We recommend that you change the SID type only on services that you want to use in firewall rules, and that you change the SID type to UNRESTRICTED.
It says in the page to use the command
sc sidtype <Type> <ServiceName>
however for me the sc tool itself says to use this:
sc sidtype <ServiceName> <Type>
Maybe the service must also run under the "Network Service" account. I did not quite get my service running. EDIT: My problem was due to WCF and not this.
精彩评论