2

I have a Raspberry Pi 2 with Windows 10 ioT installed. How do I set the IP Address statically in code?

Bill Greer
  • 3,046
  • 9
  • 49
  • 80

5 Answers5

4

You can do this by connecting remotely to your device via Powershell and running "netsh".

You can perform a variety of tasks using the Netsh command-line utility, including configuring the IP addresses of network adapters in Windows.

Here’s how to configure a static IP address:

netsh interface ip set address "connection name" static 192.168.0.101 255.255.255.0 192.168.0.1

NOTE: The default connection names are Local Area Connection for wired adapters and Wireless Network Connection for Wi-Fi adapters. The IP address order: client IP, subnet mask, and gateway IP.

Here’s how to configure the DNS addresses:

netsh interface ip add dns "connection name" 208.67.222.222

netsh interface ip add dns "connection name" 208.67.220.220 index=2

NOTE: Remember to replace the connection names and IP addresses.

Paul DeCarlo
  • 416
  • 2
  • 10
2

Now it can be done directly with Windows Device Portal (with your browser)

enter image description here

Gianluca Demarinis
  • 1,964
  • 2
  • 15
  • 21
1

The short answer is that it cannot be done via code at this time.

Bill Greer
  • 3,046
  • 9
  • 49
  • 80
0

First start the session with iOT via Windows PowerShell Using PowerShell to connect and configure a device running Windows 10 IoT Core

Then follow How to Change Your IP Address Using PowerShell

Chitta
  • 206
  • 2
  • 6
0

I guess It's a bit late, but after several research, the only solution I have found out that works so far (C#) is using ShellStream class from SSH.NET (Renci):

 SshClient client = new SshClient(host, username, password);
 client.Connect();

 ShellStream stream = client.CreateShellStream("shellName", 80, 24, 800, 600, 1024);

Then you can manipulate the stream through StreamReader/StreamWriter and call writeLine() to introduce the cmds into the Shell.

PS: You need to install SSH.NET using the Nuget Manager, by typing the next line on the console: Install-Package SSH.NET -Pre

Hope It helps.