Solved

Changing windows TCP/IP settings from java app.

Posted on 2006-07-07
24
285 Views
Last Modified: 2008-02-01
Hi all,

I need to create a java app that will automatically change the IP Address and gateway of a windows machine based on the time of day.
If at all possible, the app should also contain code to limit the bandwidth usage through a specific network card(or all bandwidth usage if that isn't possible)

I don't need help with the apps logic, but I have no idea where to start for changing the TCP/IP settings, and even less of a clue regarding the bandwidth limiting...

Any ideas?
0
Comment
Question by:riaancornelius
  • 8
  • 5
  • 5
  • +2
24 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 17056566
I don't think you can do it with pure java. You will have to resort to jni: http://java.sun.com/j2se/1.4.2/docs/guide/jni/
0
 
LVL 92

Expert Comment

by:objects
ID: 17056570
not really a Java question as you'll need native code to implement it.
So I'd suggest asking in one of the Windows TA's :)
0
 
LVL 35

Expert Comment

by:girionis
ID: 17056573
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 150 total points
ID: 17056574
You're going to need registry setting code to do that?

http://www.winguides.com/registry/display.php/269/
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17056576
I was hoping there'd be some library that would hide the native code from me :)
0
 
LVL 35

Expert Comment

by:girionis
ID: 17056582
You can use the library in my link and then write a wrapper that calls it.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17056588
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17056590
CEHJ, That would make it simple to create IP Changing part. thanks.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17056592
Be careful - you might need to reboot the box too
0
 
LVL 92

Expert Comment

by:objects
ID: 17056602
changing the registry is the easy part, lots of libs around for doing that :)

0
 
LVL 92

Expert Comment

by:objects
ID: 17056606
to reboot, use exec() to run:

rundll32.exe shell32.dll,SHExitWindowsEx 2
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17056611
>> changing the registry is the easy part, lots of libs around for doing that :)
Indeed. Sorry Girionis, There's simpler ways of doing it than your link.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 9

Author Comment

by:riaancornelius
ID: 17056614
>> to reboot, use exec() to run:
>> rundll32.exe shell32.dll,SHExitWindowsEx 2

I was really hoping rebooting wouldn't be necessary...
0
 
LVL 35

Assisted Solution

by:girionis
girionis earned 150 total points
ID: 17056617
>  Sorry Girionis, There's simpler ways of doing it than your link.

No problem. This is the point fo a forum, people talk and exchange ideas :) I learned something too.

Since you will go with CEHJ's suggestion you can have a look here: http://www.bayequities.com/tech/Products/jreg_key.shtml for another library that reads the registry.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17056623
>>I was really hoping rebooting wouldn't be necessary...

It may not be, but wouldn't surprise me
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17056624
>> Since you will go with CEHJ's suggestion you can have a look here...
Will look at that one too. Thanks
0
 
LVL 13

Accepted Solution

by:
Webstorm earned 200 total points
ID: 17057479
Hi riaancornelius,

You can call netsh program:

Runtime.getRuntime.exec(new String[]{
      "netsh",  // C:\WINNT\system32\netsh.exe
      "interface","ip","set","address","Connection name","static",
      "192.168.0.1",      // <-- IP address
      "255.255.255.0",  //  <- network mask
      "192.168.0.254"   // <- gateway
       });
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 17057490
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17057760
thanx webstorm. That's insanely easy :) Pity it's only from WIN2K...
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17120678
Webstorms way really is easiest, but it only works on win2k and later, so I'm also splitting points with CEHJ and Girionis whose solutions will work (with some effort...) on any version of windows.

Hope everybody is happy with this.
0
 
LVL 35

Expert Comment

by:girionis
ID: 17120746
:)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17121200
:-)
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 17121362
:-)
0
 
LVL 9

Author Comment

by:riaancornelius
ID: 17121389
:)
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now