The RPC server is unavailable from .NET over AWS

4

I am trying to access EC2 machines remotely to get some info using C#. I wrote code as below:-

ConnectionOptions options = new ConnectionOptions
{
Username = serverspace.ServerIP + @"\xxxxxx",
Password = "xxxxxxx",
Impersonation = ImpersonationLevel.Impersonate,
EnablePrivileges = true
};

ManagementScope scope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", serverspace.ServerIP), options);

scope.Connect();

But an RPC exception is thrown as below:- The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Management.ManagementScope.InitializeGuts(Object o) at System.Management.ManagementScope.Initialize()

1- Is the problem in the code? 2- Do I need to adjust anything in all machines firewall?

amazon-ec2
wmi
windows
asked on Server Fault Apr 23, 2013 by Bassam Gamal

1 Answer

2

RPC firewall ports are documented here:

Service overview and network port requirements for Windows
-Remote Procedure Call (RPC):
http://support.microsoft.com/kb/832017#method39

System service name: RpcSs  
Application protocol    Protocol    Ports  
RPC TCP 135  
RPC over HTTPS  TCP 593  
NetBIOS Datagram Service    UDP 138  
NetBIOS Name Resolution UDP 137  
NetBIOS Session Service TCP 139  
SMB TCP 445  

Additionally, you need the "high ports" range 49152 through 65535.

answered on Server Fault Apr 23, 2013 by Greg Askew

User contributions licensed under CC BY-SA 3.0