Saturday, March 28, 2020

PowerNSX | Add mulitple static route in NSX Edge

Good Day Folks,

During one of the activity, I had a requirement to put multiple (20-25) static routes on NSX edge and doing it one by one and manually is a headache, you know that. right?

So, I thought to do it through power NSX. Below is the code-

#Start here

Connect-NSXServer -NSXserver 192.168.110.42
$nsxedges = (Get-nsxedge -objectid edge-3).id
$subnets = '172.16.32.0/24','172.22.12.0/24'      #add all the network which you want to add in static route
$nexthop = '8.8.8.8'

Foreach($subnet in $subnets){
Foreach($nsxedge in $nsxedges){

Get-NsxEdge -ObjectId $nsxedge | Get-NsxEdgerouting | New-NsxEdgeStaticRoute -vNic 0 -Network $subnet -NextHop $nexthop -MTU 9000 -AdminDistance 1 -Confirm:$false
}
}
#End here

Refer to below output for an example



Hope it will help you. Let me know if any doubt or any error.


Thank you,
vCloudNotes

0 comments:

Post a Comment

Sponsor

AD BANNER
Powered by Blogger.
The Magazine

Text Widget

Facebook

Extra Ads

AD BANNER

Welcome to my Notes!

Hello Folks, My name is Gautam Johar. Actively working on VMware Cloud and keen to learn new and latest cloud technologies in market. Love ...

Contact Form

Name

Email *

Message *

Followers



Labels

Translate

Breaking

Random Posts

Follow Us

On Linkedin

Recent Posts

Recent Comments

Header Ads

Popular Posts

Popular Posts

Recent Posts

Text Widget

Search This Blog

Copyright © test blog | Powered by Blogger
Design by Saeed Salam | Blogger Theme by NewBloggerThemes.com