Configure a static network

Disable DHCP to configure a static network.
  1. To disable the DHCP service, set the
    DhcpEnabled
    variable value to
    False
    and set the IP address and mask properties.
    foreach(var networkInterface in systemNode.NetworkInterfaces) { if (networkInterface.InterfaceName == "LAN") { networkInterface.DhcpEnabled = false; networkInterface.IPAddress = "10.10.0.1"; networkInterface.IPAddressVariable.Mask = "255.255.0.0"; } }
  2. To create additional IP addresses for the network, create a variable for each additional IP address and add them to the
    AdditionalIPAddresses
    collection.
    TIP: Setting the values for the
    DNS1
    ,
    DNS2
    , and
    DefaultGateway
    servers would have no effect in this case. You can only set the
    DNS1
    ,
    DNS2
    , and
    DefaultGateway
    properties for the network.
    foreach (var networkInterface in systemNode.NetworkInterfaces) { if (networkInterface.InterfaceName == "LAN") { var additionalIPAddressVariable = InformationModel.MakeVariable<MaskedIPAddress>("MyAdditionalIP", OpcUa::DataTypes.String); additionalIPAddressVariable.SetValue(ipAddress); additionalIPAddressVariable.Mask = mask; networkInterface.AdditionalIPAddresses.Add(additionalIPAddressVariable); } }
  3. Explicitly set the
    DNS1
    ,
    DNS2
    , and
    DefaultGateway
    servers. For these parameters it is allowed not to enter any value.
    foreach(var networkInterface in systemNode.NetworkInterfaces) { if (networkInterface.InterfaceName == "WAN") { networkInterface.DhcpEnabled = false; networkInterface.IPAddress = "10.10.0.1"; networkInterface.IPAddressVariable.Mask = "255.255.0.0"; networkInterface.DNS1 = "1.1.1.1"; networkInterface.DNS2 = ""; networkInterface.DefaultGateway = "192.168.1.1"; } }
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.