LIST natpf rules in Virtualbox/Vagrant

后端 未结 5 1938
执念已碎
执念已碎 2021-02-04 06:13

I often get errors like this when running Vagrant:

VBoxManage: error: A NAT rule of this name already exists
VBoxManage: error: Details: code NS_ERROR_INVALID_AR         


        
5条回答
  •  粉色の甜心
    2021-02-04 06:33

    I came here with the same problem; with your hint about deleting the rule I found that you can use the VirtualBox GUI to find the rules and delete them.

    Of course, this only works when you are working on a machine with a GUI desktop.

    • Open the VirtualBox manager
    • Open the settings for the box in question (rmb -> settings, or the gear icon)
    • Select Network from the list on the left and open the Port Forwarding dialogue

    From here you'll be able to directly remove the rules.

    http://i.stack.imgur.com/6fQQc.png


    Looking at the rules, it seems they just get a name that is equal to the port being set. So you can also look at the Vagrantfile, and search for a line like this:

    db.vm.network :forwarded_port, guest: 5432, host: 5432
    

    And guess that the name of the rule will be 5432. The name of the rule for forwarding the ssh port 22, is called ssh

    $ vboxmanage modifyvm "vbox-id" --natpf1 delete "5432"
    

提交回复
热议问题