Forum Discussion
Editing Virtual server IPs via script
Hey guys! I have a BIG-IP LTM running version 11.6. I need to create a one time script that I can change all the IP addresses of my Virtual servers quickly. We are changing our IP Block and want to minimize downtime.
8 Replies
- shaggy
Nimbostratus
The TMSH command to modify a virtual server's IP address is:
modify ltm virtual vs-name destination 1.2.3.4:80
This might help you generate the commands (run in bash):
tmsh list ltm virtual destination | tr '\n' ' ' \ | sed 's/ \+/ /g;s/ltm virtual/\ntmsh modify ltm virtual/g;s/nation 1\.1\.1/nation 2.2.2/g';echo
where 1.1.1 are the old octets being replaced with 2.2.2
- Jason_40769
Nimbostratus
Thank you so much Shaggy this will help out greatly!
- RiverFish
Altostratus
I'm having trouble with this one. Maybe it's because I'm running version 11.5.1. Here's what I did:
- Created a file named bash.sh in the /shared folder.
- Ran the following command: chmod 755 /shared/bash.sh
- Ran the following command: bash /shared/bash.sh
The output looked correct, the desired octet was changed:
modify ltm virtual vs-name { destination 10.10.207.x:80 }
But, the actual VS destinations were not changed. Below is the contents of the bash.sh file:
!/bin/bash tmsh list ltm virtual destination | tr '\n' ' ' \ | sed 's/ \+/ /g;s/ltm virtual/\nmodify ltm virtual/g;s/nation 10\.10\.206/nation 10.10.207/g';echo
- shaggy
Nimbostratus
the command is meant to generate the commands that can then either be put into a script or run manually. the following should generate a bash script with 'tmsh modify ltm virtual...' commands: echo '!/bin/bash' > /shared/bash2.sh; tmsh list ltm virtual destination | tr '\n' ' ' | sed 's/ \+/ /g;s/ltm virtual/\ntmsh modify ltm virtual/g;s/nation 10\.10\.206/nation 10.10.207/g' >> /shared/bash2.sh; chmod 755 /shared/bash2.sh
- RiverFish_95049
Nimbostratus
I'm having trouble with this one. Maybe it's because I'm running version 11.5.1. Here's what I did:
- Created a file named bash.sh in the /shared folder.
- Ran the following command: chmod 755 /shared/bash.sh
- Ran the following command: bash /shared/bash.sh
The output looked correct, the desired octet was changed:
modify ltm virtual vs-name { destination 10.10.207.x:80 }
But, the actual VS destinations were not changed. Below is the contents of the bash.sh file:
!/bin/bash tmsh list ltm virtual destination | tr '\n' ' ' \ | sed 's/ \+/ /g;s/ltm virtual/\nmodify ltm virtual/g;s/nation 10\.10\.206/nation 10.10.207/g';echo
- shaggy
Nimbostratus
the command is meant to generate the commands that can then either be put into a script or run manually. the following should generate a bash script with 'tmsh modify ltm virtual...' commands: echo '!/bin/bash' > /shared/bash2.sh; tmsh list ltm virtual destination | tr '\n' ' ' | sed 's/ \+/ /g;s/ltm virtual/\ntmsh modify ltm virtual/g;s/nation 10\.10\.206/nation 10.10.207/g' >> /shared/bash2.sh; chmod 755 /shared/bash2.sh
- RiverFish
Altostratus
That is slick. Thank you!
If you are sure about the result, you can do it "on the fly". Please don´t forget saving to startup config:
tmsh list ltm virtual destination | tr '\n' ' ' | sed 's/ \+/ /g;s/ltm virtual/\ntmsh modify ltm virtual/g;s/nation 10\.131\.131/nation 10.132.132/g' | bash +x tmsh save sys config
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com