Extensions Network

New stuff in the VI Toolkit Extensions: Part 1, Routing

One nice new addition to ESX 4 is the ability to manage the complete routing table through the API, something that you had to do through the service console in previous releases.

So, how does PowerCLI help with automating all of this? Well, not much, really, PowerCLI doesn’t have any cmdlets related to routing. But this wouldn’t be a very interesting blog post if that was the end of the story. The nice thing about PowerCLI is that it gives you full access to VMware’s extremely powerful platform, which makes it easy to fill in any missing pieces we haven’t gotten to yet.

We have such a thing in the form of the VI Toolkit Community Extensions. One of the recent additions to the extensions is a set of commands that give you total control over ESX routing, and in a way that is compatible with all of PowerCLI’s cmdlets.

The new functions are as follows:

This stuff will look familiar to anyone who has used our cmdlets. If you’ve used our cmdlets before, chances are these will work the way you expect them to without a great deal of additional learning. Once you load the extensions you can run help on any of these function names and get a listing of the options they support.

Below is a quick run-down on how this stuff works. The first and easiest thing to do is to see what routes you have. I have an ESX 4 host with an IP address of The key thing to note is that Get-TkeVMHostRoute requires a VMHost argument, and also allows you to pipe it in. To get a listing of its routes I run:

Here’s some sample output:


With ESX 4 there are 3 types of routes, host routes which apply to the host, console routes, which apply to the service console (you won’t have these if you use ESXi) and the routing table. Above you can see that I have a host route and 3 entries in my routing table, and that my default route is

Let’s see what adding and removing routing table entries looks like. Let’s suppose I can use to reach the network. Here’s how to do it:

Pretty simple, really. Here are the results of that.


New-TkeVMHostRoute can handle all 3 types of routes. Run help New-TkeVMHostRoute to learn more about it.

To remove routes from the routing table, all you do is pipe a route into Remove-TkeVMHostRoute, like this:


Something that’s not immediately obvious is how you change the host or service console route, since there’s no Set-TkeVMHostRoute. In truth there should be a Set-TkeVMHostRoute and probably will be one at some point. But for now this can be done using New-TkeVMHostRoute, which will just override any existing settings.


Changing your service console IP is similar, except you will also need to specify your GatewayDevice. If you have multiple service console IPs you can set each of them by specifying different gateway devices.

If this stuff looks useful to you, be sure to check out the VI Toolkit Extensions for this and a lot more great stuff. You should keep in mind that the extensions require PowerShell v2 CTP3, which is still in technical preview mode. But if that’s something you can use anyway you’ll find it to be extremely helpful.


One comment has been added so far

Leave a Reply

Your email address will not be published. Required fields are marked *