VMware Cloud Community
davidjerwood
Enthusiast
Enthusiast

Shutdown Script - Release IP, DNS & Shutdown

I have 2 ESX 3.5 Cluster each consisting of 4 ESX Hosts. 1 Cluster is at Site A and the other Cluster at Site B. We have different VLANS at each site. Our virtual machines are configured to vmotion when needed between the 4 host in each cluster but not across site.

For DR we would migrate all vms from site A to site B or vice versa. But due to the different vlans we currently have to run a ipconfig /release all then shutdown each vm, migrate to Site B and power them on, to ensure that each machine picks up a new ip address and registers in DNS.

Does anybody have a script that I could use to do the same thing as at the moment it is a manual job. Or can anyone suggest a better solution. Apart from having a strethed vlan as this is not an option Smiley Sad

0 Kudos
5 Replies
kjb007
Immortal
Immortal

I would create a batch file to do the ip release and reboot and whatever else you needed to do, and keep that in a safe place on the server's filesystem. When you needed to implement, I'd use something like rcmd or psexec to create a scheduled task with schtasks to execute your script. This way the server will run the script to execute your tasks and be ready to go, and can be scripted fairly easily.

-KjB

vExpert/VCP/VCAP vmwise.com / @vmwise -KjB
0 Kudos
Rumple
Virtuoso
Virtuoso

I wouldn't worry about releasing the IP or DNS before shutting down unless you expect DHCP to not be available for when the machines boot up.

When the machines bootup they will broadcast for a dhcp server and ask the responding server if they can keep their previous IP. The DHCP server should respond with a nak (since it won't have that scope configured) and then the server will go through the normal process of asking for a new IP and registering itself in DNS.

What I would do though is ensure you configure collision detection (basically add in 1-2 pings to the DHCP server configuration) incase too many machines startup at the same time. It can avoid possible issues with ip conflicts.

0 Kudos
RParker
Immortal
Immortal

I wouldn't worry about releasing the IP or DNS before shutting down unless you expect DHCP to not be available for when the machines boot up.

The reason you want to release the IP before shutting down, is because if the VM's come up on a different segment, they will have 2 IP's. This can cause a problem if you contact the VM's via FQDN. So that's the reason for the release before shutdown.

The machines will register, but the OLD DNS will still be valid until the DHCP releases the IP at the configured time, if you force it, you won't have to worry about the time limit.

0 Kudos
Rumple
Virtuoso
Virtuoso

The reason you want to release the IP before shutting down, is because if the VM's come up on a different segment, they will have 2 IP's.

I will respectfully disagree here. A machine with DHCP cannot get 2 ip's...it will either get a new IP or it will try to retain the original IP (if no DHCP server responds). If it keeps the original IP it's not going to matter as it will not be accessible to anyone. After 50% of the dhcp lease time it originally had expires it will try to contact a dhcp server again. After the dhcp lease time expires it will keep trying to find a dhcp server until one responds.

The machines will register, but the OLD DNS will still be valid until the DHCP releases the IP at the configured time, if you force it, you won't have to worry about the time limit.

In this instance the DNS and network design will determine what happens. If the DNS is AD integrated and the server comes up in DR (and the DR DNS server is in sync with production) then the server will update DR when it gets the new lease and production will be updated based upon the Site link replication schedule.

If the server doesn’t get a new IP then it won't matter about DNS as no one is going to find the server anyhow.

If the DR is isolated, then what is going to happen is the server will come up in DR and update the DR DNS server and only the DR servers will have the new IP. It doesn't really matter what happens in production as nothing in production will ever know what happened in DR anyhow.

0 Kudos
davidjerwood
Enthusiast
Enthusiast

Does anyone have an example of a script I could use for this. That I could amend for my environment?

0 Kudos