A machine can have zero or more network interfaces, IP addresses etc. The answer to your question is not a single answer but involves a list in each case.
To get the IP addresses and subnet mask for each interface:
using System;
using System.Net.NetworkInformation;
public class blahblah
{
public static void Main()
{
NetworkInterface[] Interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach(NetworkInterface Interface in Interfaces)
{
if(Interface.NetworkInterfaceType == NetworkInterfaceType.Loopback) continue;
Console.WriteLine(Interface.Description);
UnicastIPAddressInformationCollection UnicastIPInfoCol = Interface.GetIPProperties().UnicastAddresses;
foreach(UnicastIPAddressInformation UnicatIPInfo in UnicastIPInfoCol)
{
Console.WriteLine("\tIP Address is {0}", UnicatIPInfo.Address);
Console.WriteLine("\tSubnet Mask is {0}", UnicatIPInfo.IPv4Mask);
}
}
}
}
To print the gateway:
public void PrintDefaultGateway()
{
var defaultGateway =
from nics in NetworkInterface.GetAllNetworkInterfaces()
from props in nics.GetIPProperties().GatewayAddresses
where nics.OperationalStatus == OperationalStatus.Up
select props.Address.ToString();
Console.WriteLine("\tGateway is {0}", defaultGateway.First());
}