For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

lizunjjg's avatar
lizunjjg
Icon for Cirrus rankCirrus
Jun 20, 2019

curl restAPI LTM + AFM

hi guys :

I used RESTAPI to create the AFM policy , but VIP cant call this policy.

This is my code and related code error:

[root@localhost /]# curl -sk -u 'admin:admin' -H "Content-Type:application/json" -X PUT https://10.1.10.66/mgmt/tm/ltm/virtual/ -d '{"name":"vs_ddos","fwEnforcedPolicy":"policy_test"}'

{"code":403,"message":"Operation is not supported on component /ltm/virtual.","errorStack":[],"apiError":1}

 

1 Reply

  • What works for me is:

    • Retrieve the configuration of the virtual server.
    $ curl -sk -u 'user:pass' -H "Content-Type: application/json" https://10.23.92.5/mgmt/tm/ltm/virtual/~Common~vs_test
    {"kind":"tm:ltm:virtual:virtualstate","name":"vs_test","partition":"Common","fullPath":"/Common/vs_test","generation":59297,"selfLink":"https://localhost/mgmt/tm/ltm/virtual/~Common~vs_test?ver=14.1.0.3","addressStatus":"yes","autoLasthop":"default","cmpEnabled":"yes","connectionLimit":0,"creationTime":"1970-01-01T00:00:00Z","destination":"/Common/10.23.98.218:80","enabled":true,"gtmScore":0,"ipProtocol":"tcp","lastModifiedTime":"2019-06-20T12:17:32Z","mask":"255.255.255.255","mirror":"disabled","mobileAppTunnel":"disabled","nat64":"disabled","pool":"/Common/pool_test","poolReference":{"link":"https://localhost/mgmt/tm/ltm/pool/~Common~pool_test?ver=14.1.0.3"},"rateLimit":"disabled","rateLimitDstMask":0,"rateLimitMode":"object","rateLimitSrcMask":0,"securityNatPolicy":{"useDevicePolicy":"no","useRouteDomainPolicy":"no"},"serviceDownImmediateAction":"none","source":"0.0.0.0/0","sourceAddressTranslation":{"type":"automap"},"sourcePort":"preserve","synCookieStatus":"not-activated","throughputCapacity":"infinite","translateAddress":"enabled","translatePort":"enabled","vlansDisabled":true,"vsIndex":70,"rules":["/Common/test","/Common/woff_file"],"rulesReference":[{"link":"https://localhost/mgmt/tm/ltm/rule/~Common~test?ver=14.1.0.3"},{"link":"https://localhost/mgmt/tm/ltm/rule/~Common~woff_file?ver=14.1.0.3"}],"policiesReference":{"link":"https://localhost/mgmt/tm/ltm/virtual/~Common~vs_test/policies?ver=14.1.0.3","isSubcollection":true},"profilesReference":{"link":"https://localhost/mgmt/tm/ltm/virtual/~Common~vs_test/profiles?ver=14.1.0.3","isSubcollection":true}}
    • Take the output and insert "fwEnforcedPolicy":"/Common/BIGIP_POLICY" between "enabled":true and "gtmScore":0. It seems to be picky about the place you add the data. Use this modified data to modify the virtual server.
    $ curl -sk -u 'user:pass' -H "Content-Type: application/json" -X PUT https://10.23.92.5/mgmt/tm/ltm/virtual/~Common~vs_test -d '{"kind":"tm:ltm:virtual:virtualstate","name":"vs_test","partition":"Common","fullPath":"/Common/vs_test","generation":59269,"selfLink":"https://localhost/mgmt/tm/ltm/virtual/~Common~vs_test?ver=14.1.0.3","addressStatus":"yes","autoLasthop":"default","cmpEnabled":"yes","connectionLimit":0,"creationTime":"1970-01-01T00:00:00Z","destination":"/Common/10.23.98.218:80","enabled":true, "fwEnforcedPolicy":"/Common/BIGIP_POLICY", "gtmScore":0,"ipProtocol":"tcp","lastModifiedTime":"2019-06-20T12:09:45Z","mask":"255.255.255.255","mirror":"disabled","mobileAppTunnel":"disabled","nat64":"disabled","pool":"/Common/pool_test","poolReference":{"link":"https://localhost/mgmt/tm/ltm/pool/~Common~pool_test?ver=14.1.0.3"},"rateLimit":"disabled","rateLimitDstMask":0,"rateLimitMode":"object","rateLimitSrcMask":0,"securityNatPolicy":{"useDevicePolicy":"no","useRouteDomainPolicy":"no"},"serviceDownImmediateAction":"none","source":"0.0.0.0/0","sourceAddressTranslation":{"type":"automap"},"sourcePort":"preserve","synCookieStatus":"not-activated","throughputCapacity":"infinite","translateAddress":"enabled","translatePort":"enabled","vlansDisabled":true,"vsIndex":70,"rules":["/Common/test","/Common/woff_file"],"rulesReference":[{"link":"https://localhost/mgmt/tm/ltm/rule/~Common~test?ver=14.1.0.3"},{"link":"https://localhost/mgmt/tm/ltm/rule/~Common~woff_file?ver=14.1.0.3"}],"policiesReference":{"link":"https://localhost/mgmt/tm/ltm/virtual/~Common~vs_test/policies?ver=14.1.0.3","isSubcollection":true},"profilesReference":{"link":"https://localhost/mgmt/tm/ltm/virtual/~Common~vs_test/profiles?ver=14.1.0.3","isSubcollection":true}}'