NAT mapping table implementation in Windows 10 IOT Core

Veeravel 1 Reputation point
2020-09-03T04:11:57.457+00:00

Is the NAT table implementation supported in windows 10 IOT core?

I need to do something similar to the implementation given in the below link in for my requirement

https://www.experiencingit.net/windows/windows-server/windows-server-2016-nat-router/

Please point me any documents relevant to the same.

Windows for IoT
Windows for IoT
A family of Microsoft operating systems designed for use in Internet of Things (IoT) devices.
381 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MichaelXu-MSFT 1 Reputation point
    2020-09-04T03:19:47.803+00:00

    Windows IoT Core does not support NAT mapping table. You can find that the command Get-NetNat/Set-NetNat can not run on Windows IoT Core. You need an alternative way to do that. There are some intricacies around what gets stored in the registry for network proxies. It is better to run through the proxy APIs. Ideally this would be through the NetworkProxyCSP, but this won’t be available in IoT until RS5. Following code can enable/disable a proxy. The code can be added to an IoT console application (see below for template) and run on the device as administrator. BTW, wininet.lib needs to be added to the project properties for linking.

    int UpdateProxy(LPWSTR proxy /*<IP>:<PORT> or NULL*/)
    {
        INTERNET_PER_CONN_OPTION_LIST OptionList;
        INTERNET_PER_CONN_OPTION Options[2];
        unsigned long listSize = sizeof(INTERNET_PER_CONN_OPTION_LIST);
    
        OptionList.pszConnection = NULL;
        OptionList.dwOptionCount = 2;
        OptionList.dwSize = sizeof(OptionList);
        OptionList.pOptions = Options;
    
        Options[0].dwOption = INTERNET_PER_CONN_FLAGS_UI;
    
        bool clearProxy = (proxy == NULL);
        if (clearProxy)
        {
            Options[0].Value.dwValue |= PROXY_TYPE_DIRECT;
            Options[0].Value.dwValue &= ~PROXY_TYPE_PROXY;
            Options[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
            Options[1].Value.pszValue = NULL;
        }
        else
        {
            Options[0].Value.dwValue |= PROXY_TYPE_PROXY;
            Options[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER;
            Options[1].Value.pszValue = proxy;
        }
    
        if (!InternetSetOption(0, INTERNET_OPTION_PER_CONNECTION_OPTION, &OptionList, listSize)) 
        {
            return GetLastError();
        }
        if (!InternetSetOption(0, INTERNET_OPTION_SETTINGS_CHANGED, NULL, NULL)) 
        {
            return GetLastError();
        }
        return 0;
    }