Thank you very much Alvero, I tried the command you suggested. It worked for first VM for second one it gave the error below:
==> web1: Setting hostname...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
# Update sysconfig
sed -i 's/\(HOSTNAME=\).*/\1web1/' /etc/sysconfig/network
# Update DNS
sed -i 's/\(DHCP_HOSTNAME=\).*/\1"web1"/' /etc/sysconfig/network-scripts/ifcfg-*
# Set the hostname - use hostnamectl if available
echo 'web1' > /etc/hostname
if command -v hostnamectl; then
hostnamectl set-hostname --static 'web1'
hostnamectl set-hostname --transient 'web1'
else
hostname -F /etc/hostname
fi
# Remove comments and blank lines from /etc/hosts
sed -i'' -e 's/#.*$//' -e '/^$/d' /etc/hosts
# Prepend ourselves to /etc/hosts
grep -w 'web1' /etc/hosts || {
sed -i'' '1i 127.0.0.1\tweb1\tweb1' /etc/hosts
}
# Restart network
service network restart
Stdout from the command:
/bin/hostnamectl
Restarting network (via systemctl): [FAILED]
Stderr from the command:
Job for network.service failed because the control process exited with error code. See "systemctl status network.service" and "journalctl -xe" for details.
C:\Users\jim\Virtual-VMs\load_balancer_lab>
Any idea why ?
Kind Regards,
Jim