Forum Discussion
TMSH command to assign ASM policy to a vip.
Hello. To assign an ASM security policy to a virtual server via the GUI I would go to Local Traffic -> Virtual Servers -> Virtual Server List, click on the Virtual Server, click Security -> Policies, under Application Security Policy I would choose "Enable", then choose the Policy.
How would I accomplish the same via the TMSH command? Thanks.
3 Replies
- Nazir_52641
Cirrus
Consider the below naming conventions:
ASM Policy name: ASM_Policy
Virtual server name : HTTP_VS1
Below is the command:
tmsh create ltm policy asm_policy_HTTP_VS1 { controls add { asm } requires add { http } rules add { default { actions add { 1 { asm enable policy ASM_Policy } } ordinal 1 } } }
tmsh modify ltm virtual HTTP_VS1 policies add { asm_policy_HTTP_VS1 }
tmsh save sys config
- MarioMeas
Nimbostratus
Thank you Nazir. What's the best way to accomplish the above steps using Rest? Thanks.
- Nazir_52641
Cirrus
Get the ID of the existing ASM policy:
curl -sku admin:admin | ./jq '.items[] | "pol_name:" + .fullPath + ";api_id:" + .id'
Assign ASM policy with id ZsKuSt3CrOF9LBMAapLOkg to VS HTTP_VS1:
curl -sku admin:admin -X PATCH -H "Content-Type: application/json" -d '{ "virtualServers" : ["/Common/HTTP_VS1"] }' | ./jq
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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