LoginSignup
0
1

More than 3 years have passed since last update.

VirtualBoxのゲストOSのネットワーク設定コマンド

Last updated at Posted at 2019-05-18

諸事情により社内でVirtualBoxのゲストOSの仮想NIC(ネットワークアダプタ)をホスト側の有線と無線への割当を頻繁に切り替えるため、コマンドでの切替方法を記載する。

以下の"Attached to"と"Name"の部分の変更をコマンド化する。ゲストVMの起動中に変更することを想定する。
image.png

ネットワークアダプタへの割当コマンドの書式

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm <VM名> <nic番号> <割当タイプ> <ホスト側割当アダプタ>

VBoxManage.exe controlvmのコマンドを使用することで、起動中のVMの設定を変更できる。modifyvmのコマンドはVMが停止していないと使用できないと理解している。

無線アダプタへブリッジ接続のコマンド例

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm windows10en nic1 bridged "Intel(R) Dual Band Wireless-AC 8265"

"Intel(R) Dual Band Wireless-AC 8265"の部分は以下のようにホストWindowsのアダプタのデバイス名で、プロパティから文字列をコピーできる。
image.png

有線アダプタへブリッジ接続のコマンド例

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm windows10en nic1 bridged "Realtek USB GbE Family Controller"

NAT接続のコマンド例

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm windows10en nic1 nat

割当解除のコマンド例

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm windows10en nic1 null

NIC1の現在の割当先の確認方法

コマンド

"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo windows10en | find "NIC 1:"

出力結果

NIC 1:                       MAC: **********, Attachment: Bridged Interface 'Realtek USB GbE Family Controller', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none

.bat化

以下のコマンドを.batファイルに記載し、ワンクリックで割当先の実行できるようにすると便利。
現在の割当先の確認、一度割当解除(念のため)、NIC1を有線アダプタへ割当、変更の割当先の確認という順でコマンドを羅列する。

@echo off
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo windows10en  | find "NIC 1:"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm windows10en  nic1 null
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm windows10en  nic1 bridged "Realtek USB GbE Family Controller"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" showvminfo windows10en  | find "NIC 1:"
pause

参考URL

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1