Skip to content

Instantly share code, notes, and snippets.

@kazu69
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazu69/b26a12ffc8f7846e8016 to your computer and use it in GitHub Desktop.
Save kazu69/b26a12ffc8f7846e8016 to your computer and use it in GitHub Desktop.
boot2docker portforwarding virtualbox
VBoxManage controlvm "boot2docker-vm"
# 以下が使用できる ----------------------------
natpf<1-N> [<rulename>],tcp|udp,[<hostip>],<hostport>,[<guestip>],<guestport> |
natpf<1-N> delete <rulename> |
# ---------------------------------------------
# localhostの8080番ポートをboot2docker-vmの80番ポートにフォワーディング
# tcp-8080という名前をつけている
VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-8080,tcp,127.0.0.1,8080,,80"
# gustのipを指定しないと全てに対して適用される
VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-8080,tcp,,8080,,80"
# ポートフォワーディングの削除
VBoxManage controlvm "boot2docker-vm" natpf1 delete tcp-8080
# ポートフォワーディングの変更は削除して、追加する
# ポートフォワーディングの確認
VBoxManage showvminfo boot2docker-vm | grep '^NIC'
# ------------------------------ 以下が出力される
NIC 1: MAC: 0800276400F4, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: virtio, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings: MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 1 Rule(0): name = ssh, protocol = tcp, host ip = 127.0.0.1, host port = 2022, guest ip = , guest port = 22
NIC 1 Rule(1): name = tcp-port443, protocol = tcp, host ip = , host port = 443, guest ip = , guest port = 443
NIC 1 Rule(2): name = tcp-port8080, protocol = tcp, host ip = , host port = 8080, guest ip = , guest port = 8080
NIC 2: MAC: 0800275F2083, Attachment: Host-only Interface 'vboxnet1', Cable connected: on, Trace: off (file: none), Type: virtio, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 3: disabled
NIC 4: disabled
NIC 5: disabled
NIC 6: disabled
NIC 7: disabled
NIC 8: disabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment