Index: /trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp	(revision 17357)
+++ /trunk/src/VBox/Main/HostNetworkInterfaceImpl.cpp	(revision 17358)
@@ -105,28 +105,6 @@
 }
 
-/**
- * Initializes the host object.
- *
- * @returns COM result indicator
- * @param   aInterfaceName name of the network interface
- * @param   aGuid GUID of the host network interface
- */
-HRESULT HostNetworkInterface::init (Bstr aInterfaceName, HostNetworkInterfaceType_T ifType, PNETIFINFO pIf)
-{
-//    LogFlowThisFunc (("aInterfaceName={%ls}, aGuid={%s}\n",
-//                      aInterfaceName.raw(), aGuid.toString().raw()));
-
-//    ComAssertRet (aInterfaceName, E_INVALIDARG);
-//    ComAssertRet (!aGuid.isEmpty(), E_INVALIDARG);
-    ComAssertRet (pIf, E_INVALIDARG);
-
-    /* Enclose the state transition NotReady->InInit->Ready */
-    AutoInitSpan autoInitSpan (this);
-    AssertReturn (autoInitSpan.isOk(), E_FAIL);
-
-    unconst (mInterfaceName) = aInterfaceName;
-    unconst (mGuid) = pIf->Uuid;
-    mIfType = ifType;
-
+HRESULT HostNetworkInterface::updateConfig (struct NETIFINFO *pIf)
+{
     m.IPAddress = pIf->IPAddress.u;
     m.networkMask = pIf->IPNetMask.u;
@@ -134,4 +112,5 @@
     m.IPV6Address = composeIPv6Address(&pIf->IPv6Address);
     m.IPV6NetworkMask = composeIPv6Address(&pIf->IPv6NetMask);
+    m.IPV6DefaultGateway = composeIPv6Address(&pIf->IPV6DefaultGateway);
     m.hardwareAddress = composeHardwareAddress(&pIf->MACAddress);
 #ifdef RT_OS_WINDOWS
@@ -143,4 +122,33 @@
 #endif /* !RT_OS_WINDOWS */
 
+    return S_OK;
+}
+
+/**
+ * Initializes the host object.
+ *
+ * @returns COM result indicator
+ * @param   aInterfaceName name of the network interface
+ * @param   aGuid GUID of the host network interface
+ */
+HRESULT HostNetworkInterface::init (Bstr aInterfaceName, HostNetworkInterfaceType_T ifType, PNETIFINFO pIf)
+{
+//    LogFlowThisFunc (("aInterfaceName={%ls}, aGuid={%s}\n",
+//                      aInterfaceName.raw(), aGuid.toString().raw()));
+
+//    ComAssertRet (aInterfaceName, E_INVALIDARG);
+//    ComAssertRet (!aGuid.isEmpty(), E_INVALIDARG);
+    ComAssertRet (pIf, E_INVALIDARG);
+
+    /* Enclose the state transition NotReady->InInit->Ready */
+    AutoInitSpan autoInitSpan (this);
+    AssertReturn (autoInitSpan.isOk(), E_FAIL);
+
+    unconst (mInterfaceName) = aInterfaceName;
+    unconst (mGuid) = pIf->Uuid;
+    mIfType = ifType;
+
+    updateConfig(pIf);
+
     /* Confirm a successful initialization */
     autoInitSpan.setSucceeded();
@@ -244,4 +252,13 @@
 }
 
+STDMETHODIMP HostNetworkInterface::COMGETTER(IPV6Supported) (BOOL *aIPV6Supported)
+{
+    CheckComArgOutPointerValid(aIPV6Supported);
+
+    *aIPV6Supported = TRUE;
+
+    return S_OK;
+}
+
 /**
  * Returns the IP V6 address of the host network interface.
@@ -281,4 +298,22 @@
 
 /**
+ * Returns the IP V6 default gateway of the host network interface.
+ *
+ * @returns COM status code
+ * @param   aIPV6DefaultGateway address of result pointer
+ */
+STDMETHODIMP HostNetworkInterface::COMGETTER(IPV6DefaultGateway) (BSTR *aIPV6DefaultGateway)
+{
+    CheckComArgOutPointerValid(aIPV6DefaultGateway);
+
+    AutoCaller autoCaller (this);
+    CheckComRCReturnRC (autoCaller.rc());
+
+    m.IPV6DefaultGateway.cloneTo (aIPV6DefaultGateway);
+
+    return S_OK;
+}
+
+/**
  * Returns the hardware address of the host network interface.
  *
@@ -355,15 +390,61 @@
 STDMETHODIMP HostNetworkInterface::EnableStaticIpConfig (ULONG aIPAddress, ULONG aNetworkMask, ULONG aDefaultGateway)
 {
+#ifndef VBOX_WITH_HOSTNETIF_API
     return E_NOTIMPL;
-}
-
-STDMETHODIMP HostNetworkInterface::EnableStaticIpConfigV6 (IN_BSTR aIPV6Address, IN_BSTR aIPV6Mask)
-{
+#else
+    AutoCaller autoCaller (this);
+    CheckComRCReturnRC (autoCaller.rc());
+
+    int rc = NetIfEnableStaticIpConfig(this, aIPAddress, aNetworkMask, aDefaultGateway);
+    if (RT_FAILURE(rc))
+    {
+        LogRel(("Failed to EnableStaticIpConfigV6 with rc=%Vrc\n", rc));
+        return rc == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL;
+    }
+    return S_OK;
+#endif
+}
+
+STDMETHODIMP HostNetworkInterface::EnableStaticIpConfigV6 (IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength, IN_BSTR aIPV6DefaultGateway)
+{
+#ifndef VBOX_WITH_HOSTNETIF_API
     return E_NOTIMPL;
+#else
+    if (!aIPV6Address)
+        return E_INVALIDARG;
+    if (!aIPV6DefaultGateway)
+        return E_INVALIDARG;
+    if (aIPV6MaskPrefixLength > 128)
+        return E_INVALIDARG;
+
+    AutoCaller autoCaller (this);
+    CheckComRCReturnRC (autoCaller.rc());
+
+    int rc = NetIfEnableStaticIpConfigV6(this, aIPV6Address, aIPV6MaskPrefixLength, aIPV6DefaultGateway);
+    if (RT_FAILURE(rc))
+    {
+        LogRel(("Failed to EnableStaticIpConfigV6 with rc=%Vrc\n", rc));
+        return rc == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL;
+    }
+    return S_OK;
+#endif
 }
 
 STDMETHODIMP HostNetworkInterface::EnableDynamicIpConfig ()
 {
+#ifndef VBOX_WITH_HOSTNETIF_API
     return E_NOTIMPL;
+#else
+    AutoCaller autoCaller (this);
+    CheckComRCReturnRC (autoCaller.rc());
+
+    int rc = NetIfEnableDynamicIpConfig(this);
+    if (RT_FAILURE(rc))
+    {
+        LogRel(("Failed to EnableStaticIpConfigV6 with rc=%Vrc\n", rc));
+        return rc == VERR_NOT_IMPLEMENTED ? E_NOTIMPL : E_FAIL;
+    }
+    return S_OK;
+#endif
 }
 
Index: /trunk/src/VBox/Main/darwin/NetIfList-darwin.cpp
===================================================================
--- /trunk/src/VBox/Main/darwin/NetIfList-darwin.cpp	(revision 17357)
+++ /trunk/src/VBox/Main/darwin/NetIfList-darwin.cpp	(revision 17358)
@@ -140,2 +140,17 @@
     return VINF_SUCCESS;
 }
+
+int NetIfEnableStaticIpConfig(HostNetworkInterface * pIf, ULONG ip, ULONG mask, ULONG gw)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
+
+int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength, IN_BSTR aIPV6DefaultGateway)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
+
+int NetIfEnableDynamicIpConfig(HostNetworkInterface * pIf)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 17357)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 17358)
@@ -6438,5 +6438,5 @@
   <enum
     name="HostNetworkInterfaceType"
-    uuid="4cd97025-b31b-430b-98dd-211e85cf389f"
+    uuid="67431b00-9946-48a2-bc02-b25c5919f4f3"
   >
     <desc>
@@ -6478,4 +6478,8 @@
     </attribute>
 
+    <attribute name="IPV6Supported" type="boolean" readonly="yes">
+      <desc>Specifies whether the IP V6 is supported/enabled for the interface.</desc>
+    </attribute>
+    
     <attribute name="IPV6Address" type="wstring" readonly="yes">
       <desc>Returns the IP V6 address of the interface.</desc>
@@ -6486,4 +6490,8 @@
     </attribute>
 
+    <attribute name="IPV6DefaultGateway" type="wstring" readonly="yes">
+      <desc>Returns the IP V6 network mask of the interface.</desc>
+    </attribute>
+    
     <attribute name="hardwareAddress" type="wstring" readonly="yes">
       <desc>Returns the hardware address. For Ethernet it is MAC address.</desc>
@@ -6528,5 +6536,10 @@
         </desc>
       </param>
-      <param name="IPV6NetworkMask" type="wstring" dir="in">
+      <param name="IPV6NetworkMaskPrefixLength" type="unsigned long" dir="in">
+        <desc>
+          network mask.
+        </desc>
+      </param>
+      <param name="IPV6DefaultGateway" type="wstring" dir="in">
         <desc>
           network mask.
Index: /trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h	(revision 17357)
+++ /trunk/src/VBox/Main/include/HostNetworkInterfaceImpl.h	(revision 17358)
@@ -63,4 +63,5 @@
 #ifdef VBOX_WITH_HOSTNETIF_API
     HRESULT init (Bstr aInterfaceName, HostNetworkInterfaceType_T ifType, struct NETIFINFO *pIfs);
+    HRESULT updateConfig (struct NETIFINFO *pIfs);
 #endif
 
@@ -71,6 +72,8 @@
     STDMETHOD(COMGETTER(NetworkMask)) (ULONG *aNetworkMask);
     STDMETHOD(COMGETTER(DefaultGateway)) (ULONG *aDefaultGateway);
+    STDMETHOD(COMGETTER(IPV6Supported)) (BOOL *aIPV6Supported);
     STDMETHOD(COMGETTER(IPV6Address)) (BSTR *aIPV6Address);
     STDMETHOD(COMGETTER(IPV6NetworkMask)) (BSTR *aIPV6Mask);
+    STDMETHOD(COMGETTER(IPV6DefaultGateway)) (BSTR *aDefaultGateway);
     STDMETHOD(COMGETTER(HardwareAddress)) (BSTR *aHardwareAddress);
     STDMETHOD(COMGETTER(MediumType)) (HostNetworkInterfaceMediumType_T *aType);
@@ -79,5 +82,5 @@
 
     STDMETHOD(EnableStaticIpConfig) (ULONG aIPAddress, ULONG aNetworkMask, ULONG aDefaultGateway);
-    STDMETHOD(EnableStaticIpConfigV6) (IN_BSTR aIPV6Address, IN_BSTR aIPV6Mask);
+    STDMETHOD(EnableStaticIpConfigV6) (IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength, IN_BSTR aIPV6DefaultGateway);
     STDMETHOD(EnableDynamicIpConfig) ();
 
@@ -101,4 +104,5 @@
         Bstr IPV6Address;
         Bstr IPV6NetworkMask;
+        Bstr IPV6DefaultGateway;
         Bstr hardwareAddress;
         HostNetworkInterfaceMediumType_T mediumType;
Index: /trunk/src/VBox/Main/include/netif.h
===================================================================
--- /trunk/src/VBox/Main/include/netif.h	(revision 17357)
+++ /trunk/src/VBox/Main/include/netif.h	(revision 17358)
@@ -62,4 +62,5 @@
     RTNETADDRIPV6  IPv6Address;
     RTNETADDRIPV6  IPv6NetMask;
+    RTNETADDRIPV6  IPV6DefaultGateway;
     RTMAC          MACAddress;
     NETIFTYPE      enmMediumType;
@@ -77,4 +78,7 @@
 
 int NetIfList(std::list <ComObjPtr <HostNetworkInterface> > &list);
+int NetIfEnableStaticIpConfig(HostNetworkInterface * pIf, ULONG ip, ULONG mask, ULONG gw);
+int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength, IN_BSTR aIPV6DefaultGateway);
+int NetIfEnableDynamicIpConfig(HostNetworkInterface * pIf);
 
 #endif
Index: /trunk/src/VBox/Main/linux/NetIfList-linux.cpp
===================================================================
--- /trunk/src/VBox/Main/linux/NetIfList-linux.cpp	(revision 17357)
+++ /trunk/src/VBox/Main/linux/NetIfList-linux.cpp	(revision 17358)
@@ -159,3 +159,16 @@
 }
 
+int NetIfEnableStaticIpConfig(HostNetworkInterface * pIf, ULONG ip, ULONG mask, ULONG gw)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
 
+int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength, IN_BSTR aIPV6DefaultGateway)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
+
+int NetIfEnableDynamicIpConfig(HostNetworkInterface * pIf)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
Index: /trunk/src/VBox/Main/os2/NetIfList-os2.cpp
===================================================================
--- /trunk/src/VBox/Main/os2/NetIfList-os2.cpp	(revision 17357)
+++ /trunk/src/VBox/Main/os2/NetIfList-os2.cpp	(revision 17358)
@@ -37,2 +37,18 @@
     return VERR_NOT_IMPLEMENTED;
 }
+
+int NetIfEnableStaticIpConfig(HostNetworkInterface * pIf, ULONG ip, ULONG mask, ULONG gw)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
+
+int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength, IN_BSTR aIPV6DefaultGateway)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
+
+int NetIfEnableDynamicIpConfig(HostNetworkInterface * pIf)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
+
Index: /trunk/src/VBox/Main/solaris/NetIfList-solaris.cpp
===================================================================
--- /trunk/src/VBox/Main/solaris/NetIfList-solaris.cpp	(revision 17357)
+++ /trunk/src/VBox/Main/solaris/NetIfList-solaris.cpp	(revision 17358)
@@ -382,2 +382,17 @@
 }
 #endif
+
+int NetIfEnableStaticIpConfig(HostNetworkInterface * pIf, ULONG ip, ULONG mask, ULONG gw)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
+
+int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength, IN_BSTR aIPV6DefaultGateway)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
+
+int NetIfEnableDynamicIpConfig(HostNetworkInterface * pIf)
+{
+    return VERR_NOT_IMPLEMENTED;
+}
Index: /trunk/src/VBox/Main/win/NetIfList-win.cpp
===================================================================
--- /trunk/src/VBox/Main/win/NetIfList-win.cpp	(revision 17357)
+++ /trunk/src/VBox/Main/win/NetIfList-win.cpp	(revision 17358)
@@ -195,5 +195,5 @@
 }
 
-static HRESULT netIfAdapterConfigPath(IWbemClassObject *pObj, BSTR * pStr)
+static HRESULT netIfWinAdapterConfigPath(IWbemClassObject *pObj, BSTR * pStr)
 {
     VARIANT index;
@@ -266,5 +266,5 @@
 }
 
-static HRESULT createIpArray(SAFEARRAY **ppArray, in_addr* aIp, UINT cIp)
+static HRESULT netIfWinCreateIpArray(SAFEARRAY **ppArray, in_addr* aIp, UINT cIp)
 {
     HRESULT hr;
@@ -302,50 +302,83 @@
 }
 
-static HRESULT VBoxNetCfgWinEnableStatic(IWbemServices * pSvc, IWbemClassObject *pObj,  in_addr* aIp,  in_addr * aMask, UINT cIp)
-{
-    IWbemClassObject * pClass;
+static HRESULT netIfWinCreateIpArrayV4V6(SAFEARRAY **ppArray, BSTR Ip)
+{
+    HRESULT hr;
+    SAFEARRAY * pIpArray = SafeArrayCreateVector(VT_BSTR, 0, 1);
+    if(pIpArray)
+    {
+        BSTR val = bstr_t(Ip, false).copy();
+        long aIndex[1];
+        aIndex[0] = 0;
+        hr = SafeArrayPutElement(pIpArray, aIndex, val);
+        if(FAILED(hr))
+        {
+            SysFreeString(val);
+            SafeArrayDestroy(pIpArray);
+        }
+
+        if(SUCCEEDED(hr))
+        {
+            *ppArray = pIpArray;
+        }
+    }
+    else
+    {
+        DWORD dwError = GetLastError();
+        Assert(0);
+        hr = HRESULT_FROM_WIN32( dwError );
+    }
+
+    return hr;
+}
+
+
+static HRESULT netIfWinCreateIpArrayVariantV4(VARIANT * pIpAddresses, in_addr* aIp, UINT cIp)
+{
+    HRESULT hr;
+    VariantInit(pIpAddresses);
+    pIpAddresses->vt = VT_ARRAY | VT_BSTR;
+    SAFEARRAY *pIpArray;
+    hr = netIfWinCreateIpArray(&pIpArray, aIp, cIp);
+    if(SUCCEEDED(hr))
+    {
+        pIpAddresses->parray = pIpArray;
+    }
+    return hr;
+}
+
+static HRESULT netIfWinCreateIpArrayVariantV4V6(VARIANT * pIpAddresses, BSTR Ip)
+{
+    HRESULT hr;
+    VariantInit(pIpAddresses);
+    pIpAddresses->vt = VT_ARRAY | VT_BSTR;
+    SAFEARRAY *pIpArray;
+    hr = netIfWinCreateIpArrayV4V6(&pIpArray, Ip);
+    if(SUCCEEDED(hr))
+    {
+        pIpAddresses->parray = pIpArray;
+    }
+    return hr;
+}
+
+static HRESULT netIfWinEnableStatic(IWbemServices * pSvc, BSTR ObjPath, VARIANT * pIp, VARIANT * pMask)
+{
+    ComPtr<IWbemClassObject> pClass;
     BSTR ClassName = SysAllocString(L"Win32_NetworkAdapterConfiguration");
     HRESULT hr;
     if(ClassName)
     {
-        hr = pSvc->GetObject(ClassName, 0, NULL, &pClass, NULL);
+        hr = pSvc->GetObject(ClassName, 0, NULL, pClass.asOutParam(), NULL);
         if(SUCCEEDED(hr))
         {
-            BSTR ObjPath;
-            hr = netIfAdapterConfigPath(pObj, &ObjPath);
+            LPWSTR argNames[] = {L"IPAddress", L"SubnetMask"};
+            LPVARIANT args[] = {pIp, pMask};
+            ComPtr<IWbemClassObject> pOutParams;
+
+            hr = netIfExecMethod(pSvc, pClass, ObjPath,
+                                bstr_t(L"EnableStatic"), argNames, args, 2, pOutParams.asOutParam());
             if(SUCCEEDED(hr))
             {
-                LPWSTR argNames[] = {L"IPAddress", L"SubnetMask"};
-                VARIANT ipAddresses;
-                VariantInit(&ipAddresses);
-                ipAddresses.vt = VT_ARRAY | VT_BSTR;
-                SAFEARRAY *pIpArray;
-                hr = createIpArray(&pIpArray, aIp, cIp);
-                if(SUCCEEDED(hr))
-                {
-                    ipAddresses.parray = pIpArray;
-                    VARIANT ipMasks;
-                    VariantInit(&ipMasks);
-                    ipMasks.vt = VT_ARRAY | VT_BSTR;
-                    SAFEARRAY *pMaskArray;
-                    hr = createIpArray(&pMaskArray, aMask, cIp);
-                    if(SUCCEEDED(hr))
-                    {
-                        ipMasks.parray = pMaskArray;
-                        LPVARIANT args[] = {&ipAddresses, &ipMasks};
-                        IWbemClassObject * pOutParams;
-
-                        hr = netIfExecMethod(pSvc, pClass, ObjPath,
-                                bstr_t(L"EnableStatic"), argNames, args, 2, &pOutParams);
-                        if(SUCCEEDED(hr))
-                        {
-                        }
-                        SafeArrayDestroy(pMaskArray);
-                    }
-                    SafeArrayDestroy(pIpArray);
-                }
-                SysFreeString(ObjPath);
-            }
-            pClass->Release();
+            }
         }
         SysFreeString(ClassName);
@@ -361,28 +394,117 @@
 }
 
-static HRESULT VBoxNetCfgWinEnableDHCP(IWbemServices * pSvc, IWbemClassObject *pObj,  in_addr* aIp,  in_addr * aMask, UINT cIp)
-{
-    IWbemClassObject * pClass;
+
+static HRESULT netIfWinEnableStaticV4(IWbemServices * pSvc, BSTR ObjPath, in_addr* aIp, in_addr * aMask, UINT cIp)
+{
+    VARIANT ipAddresses;
+    HRESULT hr = netIfWinCreateIpArrayVariantV4(&ipAddresses, aIp, cIp);
+    if(SUCCEEDED(hr))
+    {
+        VARIANT ipMasks;
+        hr = netIfWinCreateIpArrayVariantV4(&ipMasks, aMask, cIp);
+        if(SUCCEEDED(hr))
+        {
+            netIfWinEnableStatic(pSvc, ObjPath, &ipAddresses, &ipMasks);
+            VariantClear(&ipMasks);
+        }
+        VariantClear(&ipAddresses);
+    }
+    return hr;
+}
+
+static HRESULT netIfWinEnableStaticV4V6(IWbemServices * pSvc, BSTR ObjPath, BSTR Ip, BSTR Mask)
+{
+    VARIANT ipAddresses;
+    HRESULT hr = netIfWinCreateIpArrayVariantV4V6(&ipAddresses, Ip);
+    if(SUCCEEDED(hr))
+    {
+        VARIANT ipMasks;
+        hr = netIfWinCreateIpArrayVariantV4V6(&ipMasks, Mask);
+        if(SUCCEEDED(hr))
+        {
+            netIfWinEnableStatic(pSvc, ObjPath, &ipAddresses, &ipMasks);
+            VariantClear(&ipMasks);
+        }
+        VariantClear(&ipAddresses);
+    }
+    return hr;
+}
+
+/* win API allows to set gw metrics as well, we are not setting them */
+static HRESULT netIfWinSetGateways(IWbemServices * pSvc, BSTR ObjPath, VARIANT * pGw)
+{
+    ComPtr<IWbemClassObject> pClass;
     BSTR ClassName = SysAllocString(L"Win32_NetworkAdapterConfiguration");
     HRESULT hr;
     if(ClassName)
     {
-        hr = pSvc->GetObject(ClassName, 0, NULL, &pClass, NULL);
+        hr = pSvc->GetObject(ClassName, 0, NULL, pClass.asOutParam(), NULL);
         if(SUCCEEDED(hr))
         {
-            BSTR ObjPath;
-            hr = netIfAdapterConfigPath(pObj, &ObjPath);
+            LPWSTR argNames[] = {L"DefaultIPGateway"};
+            LPVARIANT args[] = {pGw};
+            ComPtr<IWbemClassObject> pOutParams;
+
+            hr = netIfExecMethod(pSvc, pClass, ObjPath,
+                                bstr_t(L"SetGateways"), argNames, args, 1, pOutParams.asOutParam());
             if(SUCCEEDED(hr))
             {
-                IWbemClassObject * pOutParams;
-
-                hr = netIfExecMethod(pSvc, pClass, ObjPath,
-                                bstr_t(L"EnableDHCP"), NULL, NULL, 0, &pOutParams);
-                if(SUCCEEDED(hr))
-                {
-                }
-                SysFreeString(ObjPath);
-            }
-            pClass->Release();
+            }
+        }
+        SysFreeString(ClassName);
+    }
+    else
+    {
+        DWORD dwError = GetLastError();
+        Assert(0);
+        hr = HRESULT_FROM_WIN32( dwError );
+    }
+
+    return hr;
+}
+
+/* win API allows to set gw metrics as well, we are not setting them */
+static HRESULT netIfWinSetGatewaysV4(IWbemServices * pSvc, BSTR ObjPath, in_addr* aGw, UINT cGw)
+{
+    VARIANT gwais;
+    HRESULT hr = netIfWinCreateIpArrayVariantV4(&gwais, aGw, cGw);
+    if(SUCCEEDED(hr))
+    {
+        netIfWinSetGateways(pSvc, ObjPath, &gwais);
+        VariantClear(&gwais);
+    }
+    return hr;
+}
+
+/* win API allows to set gw metrics as well, we are not setting them */
+static HRESULT netIfWinSetGatewaysV4V6(IWbemServices * pSvc, BSTR ObjPath, BSTR Gw)
+{
+    VARIANT vGw;
+    HRESULT hr = netIfWinCreateIpArrayVariantV4V6(&vGw, Gw);
+    if(SUCCEEDED(hr))
+    {
+        netIfWinSetGateways(pSvc, ObjPath, &vGw);
+        VariantClear(&vGw);
+    }
+    return hr;
+}
+
+static HRESULT netIfWinEnableDHCP(IWbemServices * pSvc, BSTR ObjPath)
+{
+    ComPtr<IWbemClassObject> pClass;
+    BSTR ClassName = SysAllocString(L"Win32_NetworkAdapterConfiguration");
+    HRESULT hr;
+    if(ClassName)
+    {
+        hr = pSvc->GetObject(ClassName, 0, NULL, pClass.asOutParam(), NULL);
+        if(SUCCEEDED(hr))
+        {
+            ComPtr<IWbemClassObject> pOutParams;
+
+            hr = netIfExecMethod(pSvc, pClass, ObjPath,
+                                bstr_t(L"EnableDHCP"), NULL, NULL, 0, pOutParams.asOutParam());
+            if(SUCCEEDED(hr))
+            {
+            }
         }
         SysFreeString(ClassName);
@@ -498,4 +620,153 @@
 }
 
+static HRESULT netIfWinUpdateConfig(HostNetworkInterface * pIf)
+{
+    NETIFINFO Info;
+    memset(&Info, 0, sizeof(Info));
+    GUID guid;
+    HRESULT hr = pIf->COMGETTER(Id) (&guid);
+    if(SUCCEEDED(hr))
+    {
+        Info.Uuid = (RTUUID)*(RTUUID*)&guid;
+        BSTR name;
+        hr = pIf->COMGETTER(Name) (&name);
+        Assert(hr == S_OK);
+        if(hr == S_OK)
+        {
+            int rc = collectNetIfInfo(Bstr(name), &Info);
+            if (RT_SUCCESS(rc))
+            {
+                hr = pIf->updateConfig(&Info);
+            }
+            else
+            {
+                Log(("netIfWinUpdateConfig: collectNetIfInfo() -> %Vrc\n", rc));
+                hr = E_FAIL;
+            }
+        }
+    }
+
+    return hr;
+}
+
+int NetIfEnableStaticIpConfig(HostNetworkInterface * pIf, ULONG ip, ULONG mask, ULONG gw)
+{
+    HRESULT hr;
+    GUID guid;
+    hr = pIf->COMGETTER(Id) (&guid);
+    if(SUCCEEDED(hr))
+    {
+        ComPtr <IWbemServices> pSvc;
+        hr = netIfWinCreateIWbemServices(pSvc.asOutParam());
+        if(SUCCEEDED(hr))
+        {
+            ComPtr <IWbemClassObject> pAdapterConfig;
+            hr = netIfWinFindAdapterClassById(pSvc, &guid, pAdapterConfig.asOutParam());
+            if(SUCCEEDED(hr))
+            {
+                in_addr aIp[1];
+                in_addr aMask[1];
+                aIp[0].S_un.S_addr = ip;
+                aMask[0].S_un.S_addr = mask;
+
+                BSTR ObjPath;
+                hr = netIfWinAdapterConfigPath(pAdapterConfig, &ObjPath);
+                if(SUCCEEDED(hr))
+                {
+                    hr = netIfWinEnableStaticV4(pSvc, ObjPath, aIp, aMask, 1);
+                    if(SUCCEEDED(hr))
+                    {
+                        in_addr aGw[1];
+                        aGw[0].S_un.S_addr = gw;
+                        hr = netIfWinSetGatewaysV4(pSvc, ObjPath, aGw, 1);
+                        if(SUCCEEDED(hr))
+                        {
+                            hr = netIfWinUpdateConfig(pIf);
+                        }
+                    }
+                    SysFreeString(ObjPath);
+                }
+            }
+        }
+    }
+
+    return SUCCEEDED(hr) ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
+}
+
+int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, IN_BSTR aIPV6Mask, IN_BSTR aIPV6DefaultGateway)
+{
+    HRESULT hr;
+    GUID guid;
+    hr = pIf->COMGETTER(Id) (&guid);
+    if(SUCCEEDED(hr))
+    {
+        ComPtr <IWbemServices> pSvc;
+        hr = netIfWinCreateIWbemServices(pSvc.asOutParam());
+        if(SUCCEEDED(hr))
+        {
+            ComPtr <IWbemClassObject> pAdapterConfig;
+            hr = netIfWinFindAdapterClassById(pSvc, &guid, pAdapterConfig.asOutParam());
+            if(SUCCEEDED(hr))
+            {
+                BSTR ObjPath;
+                hr = netIfWinAdapterConfigPath(pAdapterConfig, &ObjPath);
+                if(SUCCEEDED(hr))
+                {
+                    hr = netIfWinEnableStaticV4V6(pSvc, ObjPath, aIPV6Address, aIPV6Mask);
+                    if(SUCCEEDED(hr))
+                    {
+                        hr = netIfWinSetGatewaysV4V6(pSvc, ObjPath, aIPV6DefaultGateway);
+                        if(SUCCEEDED(hr))
+                        {
+                            hr = netIfWinUpdateConfig(pIf);
+                        }
+                    }
+                    SysFreeString(ObjPath);
+                }
+            }
+        }
+    }
+
+    return SUCCEEDED(hr) ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
+}
+
+int NetIfEnableStaticIpConfigV6(HostNetworkInterface * pIf, IN_BSTR aIPV6Address, ULONG aIPV6MaskPrefixLength, IN_BSTR aIPV6DefaultGateway)
+{
+    return VERR_GENERAL_FAILURE;
+}
+
+int NetIfEnableDynamicIpConfig(HostNetworkInterface * pIf)
+{
+    HRESULT hr;
+    GUID guid;
+    hr = pIf->COMGETTER(Id) (&guid);
+    if(SUCCEEDED(hr))
+    {
+        ComPtr <IWbemServices> pSvc;
+        hr = netIfWinCreateIWbemServices(pSvc.asOutParam());
+        if(SUCCEEDED(hr))
+        {
+            ComPtr <IWbemClassObject> pAdapterConfig;
+            hr = netIfWinFindAdapterClassById(pSvc, &guid, pAdapterConfig.asOutParam());
+            if(SUCCEEDED(hr))
+            {
+                BSTR ObjPath;
+                hr = netIfWinAdapterConfigPath(pAdapterConfig, &ObjPath);
+                if(SUCCEEDED(hr))
+                {
+                    hr = netIfWinEnableDHCP(pSvc, ObjPath);
+                    if(SUCCEEDED(hr))
+                    {
+                        hr = netIfWinUpdateConfig(pIf);
+                    }
+                    SysFreeString(ObjPath);
+                }
+            }
+        }
+    }
+
+    return SUCCEEDED(hr) ? VINF_SUCCESS : VERR_GENERAL_FAILURE;
+}
+
 # define VBOX_APP_NAME L"VirtualBox"
 
@@ -686,55 +957,4 @@
     return VINF_SUCCESS;
 }
-
-//TODO: this is sample currently, hardcoded balues should be removed and exposed to the API
-#if 0
-static int NetIfEnableStatic()
-{
-    INetCfg *pnc;
-    LPWSTR lpszLockedBy = NULL;
-    int r = 1;
-    HRESULT hr;
-
-            hr = VBoxNetCfgWinQueryINetCfg(FALSE, VBOX_APP_NAME, &pnc, &lpszLockedBy);
-            if(hr == S_OK)
-            {
-                INetCfgComponent  *pComponent;
-                HRESULT hr = pnc->FindComponent(L"*msloop", &pComponent);
-                if(hr == S_OK)
-                {
-                    GUID guid;
-                    hr = pComponent->GetInstanceGuid(&guid);
-                    if(SUCCEEDED(hr))
-                    {
-                        IWbemServices * pSvc;
-                        hr = netIfWinCreateIWbemServices(&pSvc);
-                        if(SUCCEEDED(hr))
-                        {
-                            IWbemClassObject *pAdapterConfig;
-                            hr = netIfWinFindAdapterClassById(pSvc, &guid, &pAdapterConfig);
-                            if(SUCCEEDED(hr))
-                            {
-                                in_addr ip[1];
-                                in_addr mask[1];
-                                ip[0].S_un.S_addr = inet_addr("192.168.5.1");
-                                mask[0].S_un.S_addr = inet_addr("255.255.255.0");
-
-                                hr = VBoxNetCfgWinEnableStatic(pSvc, pAdapterConfig,  ip,  mask, 1);
-                                if(SUCCEEDED(hr))
-                                {
-                                    printf("succees!!!\n");
-                                    r = 0;
-                                }
-                            }
-                        }
-
-                    }
-                }
-            }
-
-
-    return r;
-}
-#endif
 
 int NetIfList(std::list <ComObjPtr <HostNetworkInterface> > &list)
