Yuri Slobodyanyuk Blog on Information Security 2024年07月23日
Fortigate cannot delete VDOM or other object in use problem solution
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

在尝试删除未使用的VDOM时,Fortigate可能会因引用计数不为零而报错。本文提供了通过CLI刷新引用计数并成功删除VDOM的步骤,确保了管理员在正确操作下能够绕过这一安全特性带来的障碍。

🔍 确认VDOM未使用:使用grep命令查找VDOM的所有引用,确保没有其他配置项与其关联。

🔄 刷新引用计数:通过CLI命令diagnose sys cmdb refcnt reset重置VDOM和相关接口的引用计数,解决因缓存或删除顺序不当导致的引用计数不为零的问题。

🗑️ 删除VDOM:在引用计数重置后,重新执行删除VDOM的命令,完成VDOM的删除操作。

I file it under "feature, not a bug" category - you are trying to delete someobject, say VDOM, which is NOT actually used anywhere, but the Fortigate throwsan error command fail. Return code -23. Fortigate keeps reference count ofall objects at all times, and if for any given object its reference count is not0, trying to delete it will cause an error. This is a safety feature to preventadmins deleting an object in use. In older Check Point versions -before R80, you could delete an object used in rules, and firewall would replaceit with Any, what a disaster. But back to Fortigates - this error may, unfortunatelyhappen when you deleted all references to the object, for reasons not under ourcontrol - be stuck in the cache, oryou deleted all references to the object in the wrong (to Fortigate) order. Thesolution is simple (CLI only). Let’s take an example of deleting a VDOM.

    Delete VDOM called MyVDOM:

config vdomdel MyVDOMDomain MyVDOM: used by interface, can not deleteCommand fail. Return code -23

    First, make sure the object is indeed not used:

show | grep -f MyVDOM

config vdomedit MyVDOM <---nextendconfig globalconfig sys interface        edit "ssl.MyVDOM"                set vdom "MyVDOM"                set status down                set type tunnel        nextend

We can see, that only ssl.MyVDOM interface exists in this VDOM, and it is OK -this interface is auto-created by Fortigate, and will be auto-deleted by ittogether with the VDOM.

    See what Fortigate thinks about references to the object in question:

diagnose sys cmdb refcnt show system.interface.name ssl.MyVDOM

diagnose sys cmdb refcnt show system.interface.name ssl.MyVDOMThe total reference number is 0

    Anyway, the secret command to refresh/reset reference count. Here I run it onboth - interface, and the VDOM, just in case:

diagnose sys cmdb refcnt reset system.interface.name ssl.MyVDOM

dia sys cmdb refcnt reset system.vdom.name MyVDOM

diagnose sys cmdb refcnt reset system.interface.name ssl.MyVDOMThe total reference number is reset to 0 from 1.dia sys cmdb refcnt reset system.vdom.name MyVDOMEntry used by table system.interface.name 'ssl.MyVDOM'entry used by child table gui-dashboard:id '222'... CUT...The total reference number is reset to 14 from 20

    After that, I could delete the VDOM:

config vdomdelete MyVDOMend

Resources

Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what Ipublish on Linkedin, Github, blog, and more.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Fortigate VDOM删除 引用计数
相关文章