There is an ubuntu host with multiple ips. I want to make periodical change its ips in my java application. But I do not know how to do this. Does any one know about this?
Asked
Active
Viewed 399 times
-1
-
1Just exec whatever command you would use to do it in a shell. – user207421 Mar 09 '14 at 23:02
1 Answers
1
You could use your Java application to rewrite /etc/sysconfig/network-scripts/ifcfg-ethX (or wherever your network scripts are) and set the IP address you want. Then you would need to ask your Java application to run a bash script, reloading either the device or the whole network.
I could paste a couple of examples here but you will find loads on internet. :)

Desorder
- 1,549
- 12
- 16
-
Thanks EJP and Desorder, I think it is not necessary to reboot the server after resetting ip by your way. Is it right? – PhilipSong Mar 11 '14 at 00:40
-
@PhilipSong Nah man, you don't need to reboot the whole server, you only need to reload the network. On Centos/Red Hat, you would run `#service network restart` and that is it. :) – Desorder Mar 12 '14 at 00:25