I have a Raspberry Pi 2 with Windows 10 ioT installed. How do I set the IP Address statically in code?
Raspberry PI wifi with static IP address. Once you have made the changes reboot the PI and check that the settings have stuck. Alternatively you can use the commands ifup and ifdown. So to close down the eth0 interface issue the command sudo ifdown etho then use sudo ifup etho will bring it back up again. Setting a static IP address on the Raspberry Pi rootfs partition. Configure your host computer to have an Ethernet static IP address with the following properties.
5 Answers
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.
Now it can be done directly with Windows Device Portal (with your browser)
Gianluca DemarinisGianluca DemarinisThe short answer is that it cannot be done via code at this time.
Bill GreerBill GreerFirst 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
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):
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.