We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
How to Auto Change IP Address in VestaCP
Re: How to Auto Change IP Address in VestaCP
Is this script still current? Been a lot of changes to VestaCP in 4 years.
What is the latest and greatest way to update all the IP addresses when migrating to a new server (including a floating IP I have behind NAT) ?
Did any v-* cli script get created for IP migration?
Basically my scenario is I have created a VM image which has my OS and VestaCP all preconfigured with my preferred setitngs, apps, security, etc. I like to create a new VM instance from that image and easily update to all the new IP addresses. After that I have a new instance, for hosting more websites, or for adding to a cluster.
Recommendations?
What is the latest and greatest way to update all the IP addresses when migrating to a new server (including a floating IP I have behind NAT) ?
Did any v-* cli script get created for IP migration?
Basically my scenario is I have created a VM image which has my OS and VestaCP all preconfigured with my preferred setitngs, apps, security, etc. I like to create a new VM instance from that image and easily update to all the new IP addresses. After that I have a new instance, for hosting more websites, or for adding to a cluster.
Recommendations?
Re: How to Auto Change IP Address in VestaCP
Vesta will always need to use the local IP assigned inside the VM, not the NATted floating IP. The reason for this is that Apache/nginx bind to the local IP.
Was thinking I might have a go at updating the script. What OS are you running?
You might also look at this: viewtopic.php?f=19&t=15055. It works on OSes which have /etc/apache2 as opposed to /etc/httpd
-
- Support team
- Posts: 1096
- Joined: Sat Sep 06, 2014 9:58 pm
- Contact:
- Os: Debian 8x
- Web: apache + nginx
Re: How to Auto Change IP Address in VestaCP
I don't know why you really need a script to do this actually?
Just change your IPs in your /etc/network/interfaces,
then or goto WebUI >> IP >> Re-Read IP
then do for your domains one by one or batch them
After that just rebuild Web/DNS/Email for your users and reboot your server.
I know its not a straightforward thing to change your IPs but Vesta has the functionality built in already. Changing your NIC IP is a bit of an invasive thing... so there isn't really an easier way.
Just change your IPs in your /etc/network/interfaces,
then
Code: Select all
/usr/local/vesta/bin/v-update-sys-ip
then do
Code: Select all
/usr/local/vesta/bin/v-change-web-domain-ip
After that just rebuild Web/DNS/Email for your users and reboot your server.
I know its not a straightforward thing to change your IPs but Vesta has the functionality built in already. Changing your NIC IP is a bit of an invasive thing... so there isn't really an easier way.
Re: How to Auto Change IP Address in VestaCP
I think you're rightmehargags wrote: ↑Tue Apr 24, 2018 11:05 amI don't know why you really need a script to do this actually?
Just change your IPs in your /etc/network/interfaces,
thenor goto WebUI >> IP >> Re-Read IPCode: Select all
/usr/local/vesta/bin/v-update-sys-ip
then dofor your domains one by one or batch themCode: Select all
/usr/local/vesta/bin/v-change-web-domain-ip
After that just rebuild Web/DNS/Email for your users and reboot your server.
I know its not a straightforward thing to change your IPs but Vesta has the functionality built in already. Changing your NIC IP is a bit of an invasive thing... so there isn't really an easier way.
The external ip (WAN) is not needed for hosting but is necessary for the DNS server.
VestaCP automatically changes the current external IP to the new one in all domains and registries when you run v-update-sys-ip
I use a dynamic domain that is updated automatically with the current IP through a router (DD-WRT)
Code: Select all
DDNS: host.ddns.net > X.X.X.X
Code: Select all
CRON: sudo /usr/local/vesta/bin/v-update-sys-ip */10 * * * *
Re: How to Auto Change IP Address in VestaCP
I need this feature too. I'll explain you why I need it.
I buy VPS servers from hourly providers like digitalocean, I buy some servers based on hourly billing for some hours, and then I restore my previous snapshot to create multiple VMs like my main VM, which is configured fully for my needs and it uses VestaCP.
I buy new VMs by API, so everything is done automatically, but because of IPs are changed in New VMs, VestaCP doesn't work on them.
So I need a feature/script which changes my VestaCP settings if a new IP is detected for the server.
I'll add this feature request to this topic too:
viewtopic.php?f=20&t=19502#p80628
I hope VestaCP developers add this feature in their future updates as an option in web UI settings.
Re: How to Auto Change IP Address in VestaCP
Code: Select all
OLDIPV4='' # enter here
NEWIPV4=$(curl -s vestacp.com/what-is-my-ip/)
grep -rl "$OLDIPV4" /etc | xargs sed -i "s#$OLDIPV4#$NEWIPV4#g"
find /home/*/conf/ -type f -exec sed -i "s#$OLDIPV4#$NEWIPV4#g" {} \;
mv /usr/local/vesta/data/ips/$OLDIPV4 /usr/local/vesta/data/ips/$NEWIPV4
mv /etc/apache2/conf.d/$OLDIPV4.conf /etc/apache2/conf.d/$NEWIPV4.conf
mv /etc/nginx/conf.d/$OLDIPV4.conf /etc/nginx/conf.d/$NEWIPV4.conf
grep -rl "$OLDIPV4" /usr/local/vesta/data | xargs sed -i "s#$OLDIPV4#$NEWIPV4#g"
service bind9 restart
service apache2 restart
service nginx restart
service vesta restart
-
- Support team
- Posts: 1096
- Joined: Sat Sep 06, 2014 9:58 pm
- Contact:
- Os: Debian 8x
- Web: apache + nginx
Re: How to Auto Change IP Address in VestaCP
Nice script Dpeca
and if the guys want to get the NEWIPV4 prgramatically, you can put its value as
and if the guys want to get the NEWIPV4 prgramatically, you can put its value as
Code: Select all
$(curl ipinfo.io/ip)
Re: How to Auto Change IP Address in VestaCP
$(curl ipinfo.io/ip) give the IP correctly, but $(curl -s vestacp.com/what-is-my-ip/) don't
There is a % or a # after it....
There is a % or a # after it....