Read/Write Multiple static IPv4 Address with Subnet Prefix from network device in Advanced TCP/IP Settings RRS feed

  • Question

  • Hi All,
    I need to do the below tasks from WCF service for the network device (Connected/Disconnected network device Adapter)

    • Read/Write list of static IPv4 Address with Subnet Prefix length
    • Read/Write list of static IPv4 Default Gateway address with Metric

    Is there any API available, for performing the above operations?.

    Friday, January 11, 2019 5:52 AM

All replies

  • Hi Navaneethapperumal,

    Do you want to read the client IP address information? As far as I know, we could refer to the following code snippets.

        public class MyService : IService
            public string ReadClientIP()
                OperationContext context = OperationContext.Current;
                MessageProperties properties = context.IncomingMessageProperties;
                RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
                var result=endpoint.Address + ":" + endpoint.Port.ToString();
                return result;

    There seems to be no native implementation for IPv6 addressing. But you can use the code below to get the native IPV6 address locally.

    string name = Dns.GetHostName();
    IPAddress[] ipadrlist = Dns.GetHostAddresses(name);
    foreach (IPAddress ipa in ipadrlist)
        if (ipa.AddressFamily == AddressFamily.InterNetworkV6)

    For processing network programming, we could use the following C# class library.

    IPAddress/IPEndPoint namespace (system.dll assembly) 
    Ping/PingOptions/PingReply assembly)
    Here are msdn library links.

    Feel free to let me know if there is anything I can help you.

    Best Regards

    Friday, January 11, 2019 9:36 AM