You can get the list of local IP addresses very easily:
System.Net.IPAddress[] localIPs = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName());
Unfortunately, it may not be possible to get the IP address of your router. You can get the IP address of your default gateway, which MAY be your router, with this:
ManagementObjectCollection nacs = new ManagementClass("Win32_NetworkAdapterConfiguration").GetInstances();
foreach (ManagementObject nac in nacs)
{
if ((bool) nac["ipEnabled"])
{
string[] gateways = (string[]) nac["DefaultIPGateway"];
foreach (string sGate in gateways)
{
Console.WriteLine(sGate);
}
}
}
However, it isn't guaranteed that this is your router: All my PCs sits on a Gigabit switch which connects to a 100Mbit ADSL router. The switch doesn't have a separate IP address, since it's IP's are handled by the router.