Proper way to change server ip
Proper way to change server ip
In your SSH, as root, run:
Code: Select all
OLDIPV4='' # enter here your old IP
NEWIPV4='' # enter here your new 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
Re: Proper way to change server ip
Sorry : got this message
sed: no input files
is the format correct?
OLDIPV4=’’ # x.x.x.x
NEWIPV4=‘’ # y.y.y.y
sed: no input files
is the format correct?
OLDIPV4=’’ # x.x.x.x
NEWIPV4=‘’ # y.y.y.y
Re: Proper way to change server ip
Thanks again,
Guess it is not recognizing something:
[email protected]:/home/jpsciolli# mv /usr/local/vesta/data/ips/$OLDIPV4 /usr/local/vesta/data/ips/$NEWIPV4
mv: cannot stat '/usr/local/vesta/data/ips/'$'\342\200\231\342\200\231': No such file or directory
[email protected]:/home/jpsciolli# mv /etc/apache2/conf.d/$OLDIPV4.conf /etc/apache2/conf.d/$NEWIPV4.conf
mv: cannot stat '/etc/apache2/conf.d/'$'\342\200\231\342\200\231''.conf': No such file or directory
[email protected]:/home/jpsciolli# mv /etc/nginx/conf.d/$OLDIPV4.conf /etc/nginx/conf.d/$NEWIPV4.conf
mv: cannot stat '/etc/nginx/conf.d/'$'\342\200\231\342\200\231''.conf': No such file or directory
Guess it is not recognizing something:
[email protected]:/home/jpsciolli# mv /usr/local/vesta/data/ips/$OLDIPV4 /usr/local/vesta/data/ips/$NEWIPV4
mv: cannot stat '/usr/local/vesta/data/ips/'$'\342\200\231\342\200\231': No such file or directory
[email protected]:/home/jpsciolli# mv /etc/apache2/conf.d/$OLDIPV4.conf /etc/apache2/conf.d/$NEWIPV4.conf
mv: cannot stat '/etc/apache2/conf.d/'$'\342\200\231\342\200\231''.conf': No such file or directory
[email protected]:/home/jpsciolli# mv /etc/nginx/conf.d/$OLDIPV4.conf /etc/nginx/conf.d/$NEWIPV4.conf
mv: cannot stat '/etc/nginx/conf.d/'$'\342\200\231\342\200\231''.conf': No such file or directory
Re: Proper way to change server ip
looks like you didn't enter ip inside first two variables.
it should be:
it should be:
Code: Select all
OLDIPV4='x.x.x.x'
NEWIPV4='y.y.y.y'