Configuring
networking from the ESX service console command line
To configure networking from the ESX
service console command line:
- Ensure the network adapter you want to use is currently
connected with the command:
[root@server root]# esxcfg-nics –l
The output appears similar to:
Name PCI Driver Link Speed Duplex Description
vmnic0 06:00.00 tg3 Up 1000Mbps Full Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet
vmnic1 07:00.00 tg3 Up 1000Mbps Full Broadcom Corporation NetXtreme BCM5721 Gigabit Ethernet
In the Link column, Up indicates that the network adapter is available and functioning.
- List
the current virtual switches with the command:
[root@server root]# esxcfg-vswitch –l
The output appears similar to:
Switch Name Num Ports Used Ports Configured Ports Uplinks
vSwitch0 32 3 32 vmnic0
PortGroup Name Internal ID VLAN ID Used Ports Uplinks
VM Network portgroup2 0 0 vmnic0
In the example output, there exists a virtual machine network named VM Network with no Service Console portgroup. For illustration, the proceeding steps show you how to create a new virtual switch and place the service console port group on it. - Create
a new virtual switch with the command:
[root@server root]# esxcfg-vswitch –a vSwitch1 - Create
the Service Console portgroup on this new virtual switch:
[root@server root]# esxcfg-vswitch –A “Service Console” vSwitch1
Because there is a space in the name (Service Console), you must enclose it in quotation marks.
Note: To create Service Consoles one at time, you may need to delete all previous settings. For more information, see Recreating Service Console Networking from the command line (1000266). - Up-link
vmnic1 to the new virtual switch with the command:
[root@server root]# esxcfg-vswitch –L vmnic1 vSwitch1 - If
you need to assign a VLAN, use the command:
[root@server root]# esxcfg-vswitch -v-p “Service Console” vSwitch0 where
- Verify
the new virtual switch configuration with the command:
[root@server root]# esxcfg-vswitch –l
The output appears similar to:
Switch Name Num Ports Used Ports Configured Ports Uplinks
vSwitch0 32 3 32 vmnic0
PortGroup Name Internal ID VLAN ID Used Ports Uplinks
Service Console portgroup5 0 1 vmnic0
Switch Name Num Ports Used Ports Configured Ports Uplinks
vSwitch1 64 1 64 vmnic1
PortGroup Name Internal ID VLAN ID Used Ports Uplinks
Service Console portgroup14 0 1 vmnic1 - Create
the vswif (Service Console) interface. For example, run the command:
[root@server root]# esxcfg-vswif –a vswif0 –i 192.168.1.10 –n 255.255.255.0 –p “Service Console”
[‘Vnic’ warning] Generated New Mac address, 00:50:xx:xx:xx:xx for vswif0
Nothing to flush. - Verify
the configuration with the command:
[root@esx]# esxcfg-vswif –l
Name Port Group IP Address Netmask Broadcast Enabled DHCP
v swif0 Service Console 192.168.1.10 255.255.255.0 192.168.1.255 true false - Verify the networking configuration on the ESX host. See Verifying ESX host networking configuration on the service console (1003796) .
Recreating
Service Console networking from the command line
Note: ESX 4.0
Update 2 introduces a new tool that simplifies the process of
creating or restoring networking in the ESX service console. For more
information, see Configuring or
restoring networking from the ESX service console using console-setup (1022078).
To
delete and recreate a virtual switch and Service Console from the command line:
Note: On your
system the vswif, vmnic, vSwitch numbers and network settings are
different.
- Run
the following command to list the name of the vswif adapter:
# esxcfg-vswif -l - Run
the following command to delete the vswif adapter:
# esxcfg-vswif --del vswif0 - Run
the following command to list the name of the vSwitch:
# esxcfg-vswitch -l - Run
the following command to delete the vSwitch:
# esxcfg-vswitch -d vSwitch0 - Run
the following command to create the vSwitch:
# esxcfg-vswitch -a vSwitch0 - Run
the following commands to create default port groups for vSwitch:
# esxcfg-vswitch -A "VM Network" vSwitch0
# esxcfg-vswitch -A "Service Console" vSwitch0 - Run
the following command to create the vswif adapter:
# esxcfg-vswif --add --portgroup "Service Console" --ip=nnn.nnn.nnn.nnn --netmask=255.255.255.0 vswif0 - Run
the following command to verify that the settings in the network
file are correct:
# cat /etc/sysconfig/network
NETWORKING=yes
GATEWAYDEV=vswif0
HOSTNAME=host.domain.com
GATEWAY=nnn.nnn.nnn.nnn - Run
the following commands to list all of the network adapters and associate a
vmnic which has a link status of up:
# esxcfg-nics -l
# esxcfg-vswitch -L vmnic1 vSwitch0 - Run
the following command to verify that the vmnic is associated with the
vSwitch:
# esxcfg-vswitch -l - Ping
an IP address to check for network connectivity. If the ping fails, remove
the previous vmnic from the vSwitch and try another adapter that has a
link status of up.
# esxcfg-vswitch -U vmnic1 vSwitch0
# esxcfg-vswitch -L vmnic2 vSwitch0 - Run
the following command to change the vlan ID of a vSwitch:
# esxcfg-vswitch -p "VM Network 1" -v 10 vSwitch0 - If
you make any manual changes to /etc/sysconfig/network, run the following command to restart the network
service:
# service network restart
For
information on vNetwork Distributed Switches, see Configuring vSwitch or vNetwork Distributed Switch from the command
line in ESX 4.0 (1008127).
vim-cmd vmsvc/getallvms
Start The VM
vim-cmd vmsvc/power.on
Stop The VM
vim-cmd vmsvc/power.off 48
Restart The VM
vim-cmd vmsvc/power.restart 48
If you need to restart your VM on a daily basis I would edit and add the cron job in:
vi var/spool/cron/crontabs/root
List all the commands under
vim-cmd vmsvc
List the vms & file path
vmware-cmd -l
Start the VM Machine
vmware-cmd "/vmfs/volumes/4c16a0ec-2c7ebe2a-6ad5-0011s8azz71c/OpenSolaris 2009.06/OpenSolaris 2009.06.vmx" start
Power-On or Off Status
vmware-cmd -l | sed '/^$/d' | while read VMX ; do STATE=$(vmware-cmd "${VMX}" getstate | awk ' { print $3 } ') ; echo "${VMX}" = "${STATE}" ; done
esxcfg-nics -l
vm-support -x
vm-support -X 100
vmware-cmd.pl -H 192.168.1.1 -l zawhtet
Ref:hxxp://benincosa.org/blog/?p=266
ps -auxwww | grep 100
kill -9 100
No comments:
Post a Comment