Skip to main content

Java Source Code to Change Local IP Address

Hi guys..

Try This code to change your Local IP address.


import java.io.IOException;
import java.lang.Runtime;
public class Chang_Ip {



public static void main(String args[]) throws IOException
{

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);

}


}

Comments

vimodhan said…
Thanks..It is working..But can you post to change DNS through java..


Thanks in advance....
Unknown said…
Thanks a lot ..your post very useful..
Viral said…
I want know about a code or a program, that can cange the ip address randomly with all the possible combinations in windows
Viral said…
7I want know about a code or a program, that can cange the ip address randomly with all the possible combinations in windows

that of IPv4 and IPv6

Such as op:

enter a choice:

1. change IP Address
2. Change Subnet Mask
3. Change Default gateaway Address
4. Change DNS server Address

and so....
so you would have understood
Unknown said…
not working at my laptop......kindly guide me
Spark said…
For ipv6, what should i do?