2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

esxcliコマンドでCLIにてESXi上に仮想ネットワークを作成する。

Last updated at Posted at 2019-07-15

(半分備忘録用)
esxcliコマンドを使用するとCLIにて基本的なvSphereの操作・設定が出来ます。
今回はさわりの部分だけ仮想ネットワークを作成してみます。
※出来ないことはPowerCLIの活用も考える

検証環境:NestESXi 6.7.0 Update 2にSSHで直接接続。
あらかじめインストール後DCUIで管理NWの設定、DNSの設定を済ませて、
ブラウザからHost Clientへアクセスできる状態

#仮想スイッチの作成
switch1という名前の標準仮想スイッチを追加する。

[root@nestesxi01:~] esxcli network vswitch standard add -v switch1

デフォルトのvSwitch0ではなく新たに作成したスイッチが見えることを確認する。

[root@nestesxi01:~] esxcli network vswitch standard list
vSwitch0
   Name: vSwitch0
   Class: cswitch
   Num Ports: 2560
   Used Ports: 6
   Configured Ports: 128
   MTU: 1500
   CDP Status: listen
   Beacon Enabled: false
   Beacon Interval: 1
   Beacon Threshold: 3
   Beacon Required By: 
   Uplinks: vmnic0
   Portgroups: VM Network, Management Network

switch1
   Name: switch1
   Class: cswitch
   Num Ports: 2560
   Used Ports: 1
   Configured Ports: 128
   MTU: 1500
   CDP Status: listen
   Beacon Enabled: false
   Beacon Interval: 1
   Beacon Threshold: 3
   Beacon Required By: 
   Uplinks: 
   Portgroups: 

#ポートグループの追加
新規作成した仮想スイッチにポートグループを結びつけて作成する。

[root@nestesxi01:~] esxcli network vswitch standard portgroup add -p testportgroup -v switch1

作成できているか確認

[root@nestesxi01:~] esxcli network vswitch standard portgroup list
Name                Virtual Switch  Active Clients  VLAN ID
------------------  --------------  --------------  -------
Management Network  vSwitch0                     1        0
VM Network          vSwitch0                     0        0
testportgroup       switch1                      0        0

#vmkernelポートを作成し、IPアドレスを振る

[root@nestesxi01:~] esxcli network ip interface add -p testportgroup
[root@nestesxi01:~] esxcli network ip interface ipv4 set -i vmk1 -I 192.168.1.21 -N 255.255.255.0 -t static

#UPLink用の物理ポートを仮想スイッチに結びつける
vmnicのリストを表示させ、vmnic2をUPLinkに追加

[root@nestesxi01:~] esxcli network nic list
Name    PCI Device    Driver    Admin Status  Link Status  Speed  Duplex  MAC Address         MTU  Description
------  ------------  --------  ------------  -----------  -----  ------  -----------------  ----  -----------------------------------------------
vmnic0  0000:0b:00.0  nvmxnet3  Up            Up           10000  Full    00:0c:29:a2:9c:62  1500  VMware Inc. vmxnet3 Virtual Ethernet Controller
vmnic1  0000:13:00.0  nvmxnet3  Up            Up           10000  Full    00:0c:29:a2:9c:6c  1500  VMware Inc. vmxnet3 Virtual Ethernet Controller
vmnic2  0000:1b:00.0  nvmxnet3  Up            Up           10000  Full    00:0c:29:a2:9c:76  1500  VMware Inc. vmxnet3 Virtual Ethernet Controller
vmnic3  0000:04:00.0  nvmxnet3  Up            Up           10000  Full    00:0c:29:a2:9c:80  1500  VMware Inc. vmxnet3 Virtual Ethernet Controller
[root@nestesxi01:~] esxcfg-vswitch --link=vmnic2 switch1
[root@nestesxi01:~] esxcli network vswitch standard list
vSwitch0
   Name: vSwitch0
   Class: cswitch
   Num Ports: 2560
   Used Ports: 6
   Configured Ports: 128
   MTU: 1500
   CDP Status: listen
   Beacon Enabled: false
   Beacon Interval: 1
   Beacon Threshold: 3
   Beacon Required By: 
   Uplinks: vmnic0
   Portgroups: VM Network, Management Network

switch1
   Name: switch1
   Class: cswitch
   Num Ports: 2560
   Used Ports: 4
   Configured Ports: 128
   MTU: 1500
   CDP Status: listen
   Beacon Enabled: false
   Beacon Interval: 1
   Beacon Threshold: 3
   Beacon Required By: 
   Uplinks: vmnic2
   Portgroups: testportgroup

※他の詳細なコマンドは
esxcliコマンドを引数なしで実行するまたは -?で使用方法を確認できます。

[root@nestesxi01:~] esxcli
Usage: esxcli [options] {namespace}+ {cmd} [cmd options]

    Options:
    --formatter=FORMATTER
                            Override the formatter to use for a given command. Available formatter: keyvalue, csv, xml
    --debug               Enable debug or internal use options
    --version             Display version information for the script
    -?, --help            Display usage information for the script

    Available Namespaces:
    device                Device manager commands
    esxcli                Commands that operate on the esxcli system itself allowing users to get additional information.
    fcoe                  VMware FCOE commands.
    graphics              VMware graphics commands.
    hardware              VMKernel hardware properties and commands for configuring hardware.
    iscsi                 VMware iSCSI commands.
    network               Operations that pertain to the maintenance of networking on an ESX host. This includes a wide variety of commands to manipulate virtual
                            networking components (vswitch, portgroup, etc) as well as local host IP, DNS and general host networking settings.
    nvme                  VMware NVMe driver esxcli extensions
    rdma                  Operations that pertain to remote direct memory access (RDMA) protocol stack on an ESX host.
    sched                 VMKernel system properties and commands for configuring scheduling related functionality.
    software              Manage the ESXi software image and packages
    storage               VMware storage commands.
    system                VMKernel system properties and commands for configuring properties of the kernel core system and related system services.
    vm                    A small number of operations that allow a user to Control Virtual Machine operations.
    vsan                  VMware vSAN commands

2
6
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
2
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?