Archive

Posts Tagged ‘esxi’

vsphere esxi tips

July 1st, 2013 Comments off
vicfg-<esxcfg- deprecated> and other vCLI commands, include ESXCLI<from the server with vCLI package installed OR from the vMA virtual machine OR through vcenter server<-vihost parameter>>
esxcli<better use vCLI or PowerCLI instead. directly from esxi shell<console> OR from the server with vCLI package installed OR from the vMA virtual machine OR from vsphere PowerCLI prompt by using Get-EsxCli> OR through vcenter server<-vihost parameter>
localcli <localcli commands are equivalent to ESXCLI commands, but bypass hostd. The localcli commands are only for situations when hostd is unavailable and cannot be restarted. After you run a localcli command, you must restart hostd. Run ESXCLI commands after the restart. If you use a localcli command in other situations, an inconsistent system state and potential failure can result.>
PowerCLI cmdlets<windows powershell>
Some examples:
vicfg-hostops <conn_options> --operation shutdown --force
vicfg-hostops <conn_options> --operation shutdown --cluster <my_cluster>
vmware-cmd --config esxhome.cfg -l
vmware-cmd --config esxhome.cfg '/vmfs/volumes/505f5efb-38f8b83f-e1ce-1c6f65d2477b/OracleLinux/OracleLinux.vmx' getuptime
esxcli [options] {namespace}+ {cmd} [cmd options]
esxcli --config esxhome.cfg network ip interface list
esxcli --config esxhome.cfg fcoe adapter list
esxcli --config esxhome.cfg storage nfs add -H <hostname> -s <sharepoint> -v <volumename>
esxcli --config esxhome.cfg --formatter=csv network ip interface list
esxcli --config esxhome.cfg --reason <reason> system shutdown poweroff <must be in maintenance mode>
esxcli --config esxhome.cfg --reason <reason> system shutdown reboot
esxcli <conn_options> system maintenanceMode set --enable true
~ # esxcli vm process list
UCF-ZFS001
World ID: 35425
Process ID: 0
VMX Cartel ID: 35356
UUID: 42 29 c5 ae 06 c7 19 f2-1e 85 88 eb 3f 19 6f 65
Display Name: UCF-ZFS001
Config File: /vmfs/volumes/5739ec95-8876d0ed-193d-0010e03ca4e8/UCF-ZFS001/UCF-ZFS001.vmx
~ # vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
2 UCF-ZFS001 [hyper01] UCF-ZFS001/UCF-ZFS001.vmx solaris11_64Guest vmx-10 Oracle

configure linux as a router firewall through iptables NAT

June 25th, 2013 Comments off
  • On the linux box that will act as router:

1.Turn on ip_forward:

vi /etc/sysctl.conf

net.ipv4.ip_forward = 1

sysctl -p

2.Edit /etc/sysconfig/iptables:

*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A POSTROUTING -o eth1 -j MASQUERADE #eth1 is the NIC connecting to outside network

#-A POSTROUTING -s 192.168.8.0/255.255.248.0 -o eth0 -j MASQUERADE  #allow 192.168.8.0/21 to do NAT
COMMIT

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT

3.Reload iptables:

[root@Router ~]# service iptables restart
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter nat [ OK ]
Unloading iptables modules: [ OK ]
Applying iptables firewall rules: [ OK ]
Loading additional iptables modules: ip_conntrack_netbios_n[ OK ]

[root@Router ~]# iptables -t nat -nL
Chain PREROUTING (policy ACCEPT)
target prot opt source destination

Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
MASQUERADE all -- 0.0.0.0/0 0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@Router ~]# iptables -t filter -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

On the linux box that will act as client:

1.Set default gateway to the ip address of linux router:

vi /etc/sysconfig/network

...

GATEWAY=192.168.6.1 #this is ip address of the linux router

...

2.restart network

Test

On router, the default gateway is:

0.0.0.0         10.124.184.1    0.0.0.0         UG        0 0          0 eth1

And on the linux client, we'll now be able to connect to outside network too:

[root@client ~]# ping 10.244.29.184
PING 10.244.29.184 (10.244.29.184) 56(84) bytes of data.
64 bytes from 10.244.29.184: icmp_seq=1 ttl=254 time=0.236 ms

PS:

  1. You can also make linux as firewall using NAT/iptables, more on this article: http://xinn.org/iptables-nat.html
  2. About the numbers in brackets, you can refer to the following: https://www.linuxquestions.org/questions/linux-networking-3/those-%5B-damn-brackets-%5D-in-iptables-must-be-there-for-a-reason-619556/
  3. You should turn on promiscuous mode before applying the configs in this article. If you're using Vsphere Esxi, this is the step:

promiscuous

enable vm virtualization support in esxi

June 24th, 2013 Comments off

If you want to enable your newly created VM's virtualization support, you can follow these steps:

  1. In Vm setting -> Options -> CPU/MMU Virtualization, select either the third for forth checkbox:enable_virtualization
  2. Go to esxi console, locate your VM's vmx configuration file(under /vmfs/volumes/Datastore/Nimbula_Node05 in my case), and add a line:

vhv.enable = TRUE

After these steps, your vm should now support nested virtualization. You can run egrep '(vmx|svm)' --color=always /proc/cpuinfo to confirm whether virtualization is enabled or not now.

vmware vsphere esxi vicfg esxcli localcli PowerCLI

May 21st, 2013 Comments off
vicfg-<esxcfg- deprecated> and other vCLI commands, include ESXCLI<from the server with vCLI package installed OR from the vMA virtual machine OR through vcenter server<-vihost parameter>>
esxcli<better use vCLI or PowerCLI instead. directly from esxi shell<console> OR from the server with vCLI package installed OR from the vMA virtual machine OR from vsphere PowerCLI prompt by using Get-EsxCli> OR through vcenter server<-vihost parameter>
localcli <localcli commands are equivalent to ESXCLI commands, but bypass hostd. The localcli commands are only for situations when hostd is unavailable and cannot be restarted. After you run a localcli command, you must restart hostd. Run ESXCLI commands after the restart. If you use a localcli command in other situations, an inconsistent system state and potential failure can result.>
PowerCLI cmdlets<windows powershell>
Some examples:
vicfg-hostops <conn_options> --operation shutdown --force
vicfg-hostops <conn_options> --operation shutdown --cluster <my_cluster>
vmware-cmd --config esxhome.cfg -l
vmware-cmd --config esxhome.cfg '/vmfs/volumes/505f5efb-38f8b83f-e1ce-1c6f65d2477b/OracleLinux/OracleLinux.vmx' getuptime
esxcli [options] {namespace}+ {cmd} [cmd options]
esxcli --config esxhome.cfg network ip interface list
esxcli --config esxhome.cfg fcoe adapter list
esxcli --config esxhome.cfg storage nfs add -H <hostname> -s <sharepoint> -v <volumename>
esxcli --config esxhome.cfg --formatter=csv network ip interface list
esxcli --config esxhome.cfg --reason <reason> system shutdown poweroff <must be in maintenance mode>
esxcli --config esxhome.cfg --reason <reason> system shutdown reboot
esxcli <conn_options> system maintenanceMode set --enable true