简体   繁体   中英

how to change local machine/ethernet ip address

I'm trying to make a program that can change pc/laptop ip address & subnet mask. the input I'm trying to make is similar with the interface on IPv4 properties on windows(ip/subnet, dns/alternate dns).

the ones that I can think of right now is using a netsh command to change the windows ip. what i want to do is to set/get the ethernet setting on windows

thanks in advance

You can change the registry in JAVA, wich should do the trick. These should help:

http://www.windowsreference.com/networking/dhcp-static-ip-settings-in-windows-registry/

http://www.windowsreference.com/networking/dhcp-static-ip-settings-in-windows-registry/

Other method is to call the netsh command from JAVA:

String str1="192.168.0.201";
String str2="255.255.255.0";
String[] command1 = { "netsh", "interface", "ip", "set", "address",
"name=", "Local Area Connection" ,"source=static", "addr=",str1,
"mask=", str2};
Process pp = java.lang.Runtime.getRuntime().exec(command1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM