Forwarding a Range of Ports in VirtualBox

STAN SCHWERTLY MAY 9, 2012 ARTICLES 3 COMMENTS

Doesn‘t allow forwarding a range of ports through the UI

I recently had to forward a range of ports to a VirtualBox instance. The VirtualBox GUI doesn’t provide a method for forwarding a range of ports. The VirtualBox Manual describes a way for adding the rule via the command-line:

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

This forwards any traffic arriving on port 2222 to port 22 on the virtual instance. We can use this to create a short bash loop. In the example below, we’re forwarding ports 2300-2400 to ports 2300-2400 on the virtual instance (both TCP and UDP):

for i in {2300..2400}; do
VBoxManage modifyvm "windows" --natpf1 "tcp-port$i,tcp,,$i,,$i";
VBoxManage modifyvm "windows" --natpf1 "udp-port$i,udp,,$i,,$i";
done

You can verify this by going back into the VirtualBox port forwarding page and seeing the newly configured ports. It’s just as easy to delete them:

for i in {2300..2400}; do
VBoxManage modifyvm "windows" --natpf1 delete "tcp-port$i"; 
VBoxManage modifyvm "windows" --natpf1 delete "udp-port$i"; 
done

This should suffice until the capability is added to the VirtualBox UI.

时间: 2024-10-09 06:49:49

Forwarding a Range of Ports in VirtualBox的相关文章

路由器port触发与转发---Port Forwarding & Port Triggering

What is Port Triggering? If you have not read my explanation of port forwarding do so now. You can find it here. Port triggering is pretty simple once you know what port forwarding is. Port Triggering is port forwarding with an on/off switch for the

PS-Scan ports扫描网络端口

用PS写出端口扫描 TCP139/445 AND UDP 137/138 用法简单:在c:\temp\target.txt写入多台IP地址 端口可以自己定义 以下是代码: <# This script can be used to Scan port TCP139/445 AND UDP 137/138 Need to modify Ip address under C:\temp\Target.txt first Date:2017-05-15 #> function Test-PortUD

squid对http range的处理以及range_offset_limit

range_offset_limit A range request comes from a client that wants only some subset of an HTTP response. They are sometimes used to resume a failed transfer of a large file. Squid isn't yet able to cache partial responses and thus must make a decision

The Ephemeral Port Range (各操作系统随机端口范围)

The Ephemeral Port Range A TCP/IPv4 connection consists of two endpoints, and each endpoint consists of an IP address and a port number.  Therefore, when a client user connects to a server computer, an established connection can be thought of as the

路由器端口触发与转发---Port Forwarding &amp; Port Triggering

What is Port Triggering? If you have not read my explanation of port forwarding do so now. You can find it here. Port triggering is pretty simple once you know what port forwarding is. Port Triggering is port forwarding with an on/off switch for the

【转】刚发现一个linux在线文档库。很好很强大。

原文网址:http://blog.csdn.net/longxibendi/article/details/6048231 1.网址: http://www.mjmwired.net 2.比如查看这个 proc.txt ,就在这里能找到. http://www.mjmwired.net/kernel/Documentation/filesystems/proc.txt 内核参数解释全在这里了.不过,也可以下载内核完源代码,从/usr/src/linux/Documentation/proc.tx

iptables包过滤入门指南

1. Introduction Welcome, gentle reader. It is assumed you know what an IP address, a network address, a netmask, routing and DNS are. If not, I recommend that you read the Network Concepts HOWTO. This HOWTO flips between a gentle introduction (which

FileZilla Server配置

1.在服务器上安装并配置服务端: 安装过程这里不再赘述,一直下一步,在跳出弹窗时勾选"Always connect to this server",然后点击"Connect"即可(密码可自行设置) 之后提示信息如下:Logged on代表登录成功,也代表你filezilla server软件安装成功. 问题与警告 问题:You appear to be behind a NAT router. Please configure the passive mode se

理解Docker(1):Docker 安装和基础用法

1. 安装 1.1 在 Ubuntu 14.04 上安装 Docker 前提要求: 内核版本必须是3.10或者以上 依次执行下面的步骤: sudo apt-get update sudo apt-get install apt-transport-https ca-certificates sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF7