Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Change the NP2 IP from code

NP2 ethernet ip

Best Answer JerseyTechGuy , 13 February 2013 - 11:57 AM

Yes, quite easy:

 

var interf = NetworkInterface.GetAllNetworkInterfaces()[0];interf.EnableStaticIP(<settings.staticIPAddress>, <settings.subnetMask>, <settings.defaultGateway>);interf.EnableStaticDns(new string[] { <settings.primaryDNSAddress>, <settings.secondaryDNSAddress> });
Go to the full post


  • Please log in to reply
5 replies to this topic

#1 Duefectu

Duefectu

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts

Posted 13 February 2013 - 10:55 AM

Hello:

 

It's possible to change the Netduino Plus 2 IP Address from code?

 

I want to make a build in webserver where change some program settings, including IP Address.

 

Thanks for your time!



#2 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 13 February 2013 - 11:57 AM   Best Answer

Yes, quite easy:

 

var interf = NetworkInterface.GetAllNetworkInterfaces()[0];interf.EnableStaticIP(<settings.staticIPAddress>, <settings.subnetMask>, <settings.defaultGateway>);interf.EnableStaticDns(new string[] { <settings.primaryDNSAddress>, <settings.secondaryDNSAddress> });

  • Duefectu likes this

#3 hanzibal

hanzibal

    Advanced Member

  • Members
  • PipPipPip
  • 1287 posts
  • LocationSweden

Posted 13 February 2013 - 01:51 PM

In wonder, will it stick after a reset/powercycle?



#4 Tal Tikotzki

Tal Tikotzki

    Member

  • Members
  • PipPip
  • 10 posts

Posted 13 February 2013 - 05:54 PM

In wonder, will it stick after a reset/powercycle?

Yes it will.



#5 JerseyTechGuy

JerseyTechGuy

    Advanced Member

  • Members
  • PipPipPip
  • 870 posts

Posted 13 February 2013 - 06:36 PM

I agree... yes it does.  In my project I still set it each time from the SD card from a config file, but if I don't do that the settings do stay.


  • Duefectu likes this

#6 Duefectu

Duefectu

    Advanced Member

  • Members
  • PipPipPip
  • 34 posts

Posted 13 February 2013 - 10:05 PM

Thanks to all for your responses and comments!







Also tagged with one or more of these keywords: NP2, ethernet, ip

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.