These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Run 'Change IP Addresses' automatically on boot for amazon ec2 hosts on the new forum.
I've seen the same question some times now on this forum, but I'll ask it again to see if there are new developments.
I have a very large amazon instance for heavy traffic for one of my websites. On boot the machine syncs the website and database and places itselfs in the Amazon ELB (loadbalancer), and disables the machine forwarding all the traffic to my static virtualmin machine.
This works perfectly, except for the fact that the IP address given to the machine changes everytime and Virtualmin only works with the previous, static IP.
The solution would off course be to run the Change IP Addresses script on boot automatically. Is this possible?
Howdy,
Beginning in Virtualmin 3.94, if Virtualmin detects a changed IP address, it should prompt you to update the IP's that it's configured to use.
It would only prompt the Master Admin user.
I don't know if there's a way to do that from the command line though... I can ask Jamie about that.
-Eric
While logging into Virtualmin and handling it there is the simplest way to update the IP, that's not automated... Jamie suggested the following code as an automated way of updating the IP:
You'd want to test all that though -- in particular, you'd want to make sure that "hostname -i" returns your correct Ip address.
-Eric
And where should this be executed? Not simply from shell..
Howdy,
After verifying that the above code does what you want (we haven't tested it on an EC2 system), you could put it in a shell script, and have that shell script run automatically when your system boots up.
-Eroc
Well, the 'virtualmin' command is not found in shell.. does this also apply for virtualmin GPL?
Yup, that should be available on both Virtualmin Pro and Virtualmin GPL.
It's possible that it's just not in your path... rather than "virtualmin", try running "/usr/sbin/virtualmin".
-Eric
awesome. Today I solved a problem BUT also learned the fantastic fact that a whole script enviroment exists for virtualmin!
I cannot fathom, after using webmin/virtualmin for almost 7 years what a great product it is..
this is the final script btw:
#!/bin/bash
newip=`hostname -i`
for dom in `/usr/sbin/virtualmin list-domains --name-only`; do
/usr/sbin/virtualmin modify-domain --domain $dom --shared-ip $newip
done
runs at boot (cron) and I'm all happy :)
Super, I'm glad you got that working, thanks for sharing your final script with us!