LIST natpf rules in Virtualbox/Vagrant

后端 未结 5 2001
执念已碎
执念已碎 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条回答
  •  萌比男神i
    2021-02-04 06:39

    Expanding on Andrew's answer, this lists the rules for all your VMs

    for vm in `vboxmanage list vms | awk -F'"' '$0=$2'`
    do
        echo "Rules for VM $vm"
        VBoxManage showvminfo $vm --machinereadable | awk -F '[",]' '/^Forwarding/ { printf ("Rule %s host port %-5d forwards to guest port %-5d\n", $2, $5, $7); }'
        printf '\n'
    done
    

提交回复
热议问题