VMware Arena

ESX Server Networks!!!! Networks!!!!! Networks!!!!!! in Command Line

Hey man!!!! wake up…. last friday i was struggled to change the ip address of my collegue’s lab ESX server service console. That struggle leads me to this post. thanks Anil…..

To check the IP address along with the detailed network cards assigned to the esx server:

Ifconfig -a

Output appears like this
========================================================================

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:9365 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9365 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:8127714 (7.7 MiB)  TX bytes:8127714 (7.7 MiB)

vmnic0    Link encap:Ethernet  HWaddr 00:0C:29:85:0D:76
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:100772 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5103 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:35475848 (33.8 MiB)  TX bytes:402120 (392.6 KiB)
          Interrupt:145

vmnic1    Link encap:Ethernet  HWaddr 00:0C:29:85:0D:80
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:105895 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:35894203 (34.2 MiB)  TX bytes:0 (0.0 b)
          Interrupt:129

vmnic2    Link encap:Ethernet  HWaddr 00:0C:29:85:0D:8A
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:105908 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:35895750 (34.2 MiB)  TX bytes:0 (0.0 b)
          Interrupt:137

vmnic3    Link encap:Ethernet  HWaddr 00:0C:29:85:0D:94
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:105690 errors:0 dropped:0 overruns:0 frame:0
          TX packets:228 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:35883279 (34.2 MiB)  TX bytes:13680 (13.3 KiB)
          Interrupt:145

vswif0    Link encap:Ethernet  HWaddr 00:50:56:4D:69:D1
          inet addr:192.168.0.75  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:14893 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2575 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:966513 (943.8 KiB)  TX bytes:230028 (224.6 KiB)

vswif1    Link encap:Ethernet  HWaddr 00:50:56:4F:45:B1
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:11042 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:717158 (700.3 KiB)  TX bytes:1260 (1.2 KiB)

=========================================================================

You can use “ip addr” command also to view the ip information

=========================================================================

[root@ESXTEST1 etc]# ip addr
1: lo: mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: vmnic0: mtu 1500 qdisc noop qlen 1000
    link/ether 00:0c:29:85:0d:76 brd ff:ff:ff:ff:ff:ff
3: vmnic1: mtu 1500 qdisc noop qlen 1000
    link/ether 00:0c:29:85:0d:80 brd ff:ff:ff:ff:ff:ff
4: vmnic2: mtu 1500 qdisc noop qlen 1000
    link/ether 00:0c:29:85:0d:8a brd ff:ff:ff:ff:ff:ff
5: vmnic3: mtu 1500 qdisc noop qlen 1000
    link/ether 00:0c:29:85:0d:94 brd ff:ff:ff:ff:ff:ff
6: vswif0: mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:56:4d:69:d1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.75/24 brd 192.168.0.255 scope global vswif0
7: vswif1: mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:56:4f:45:b1 brd ff:ff:ff:ff:ff:ff
9: vswif2: mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 00:50:56:43:92:be brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.96/24 brd 192.168.0.255 scope global vswif2

=========================================================================

2. To check the ESX vswitch details, port group and its ip address:
Esxcfg-vswitch -l
Outuput will appear like this:
=========================================================================
[root@ESXTEST1 ~]# esxcfg-vswitch -l
Switch Name    Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch0       32          4           32                1500    vmnic0

  PortGroup Name      VLAN ID  Used Ports  Uplinks
  Service Console     0        1           vmnic0
  VMkernel            0        1           vmnic0

Switch Name    Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch1       64          3           64                1500    vmnic2,vmnic1

  PortGroup Name      VLAN ID  Used Ports  Uplinks
  VM-10.0.0 subnet    0        0           vmnic2,vmnic1
  VM-192.168.0 subnet 0        0           vmnic2,vmnic1

Switch Name    Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch2       64          4           64                1500    vmnic3

  PortGroup Name      VLAN ID  Used Ports  Uplinks
  Service Console 2   0        1           vmnic3
  Vmotion             0        1           vmnic3
=========================================================================
From the above output,
we come to know that we have 3 virtual switches named vSwitch0,vSwitch1 and vSwitch2.
4 uplinks (physical nics in our esx server) Vmnic0,vmnic1,vmnic2,vmnic3.
vswitch0 constains 2 port group (Service Console & VMKernel), vSwitch1 contains 2 virtual machine port group (VM-10.0.0 subnet & VM-192.168.0 subnet) and Vswitch2 contains 2 port group (Service Console 2 & Vmotion) port group.

3. To get the information about Service console ports and its ip address

esxcfg-vswif -l

Output will appear like this:

=========================================================================
[root@ESXTEST1 ~]# esxcfg-vswif -l
Name     Port Group/DVPort   IP Family IP Address                              Netmask                                 Broadcast        Enabled   TYPE
vswif0   Service Console     IPv4      192.168.0.75                            255.255.255.0                           192.168.0.255    true      STATIC
vswif1   Service Console 2   IPv4      192.168.0.78                            255.255.255.0                           192.168.0.255    false     STATIC
=========================================================================
4. To get the information about vmkernel ports and its ip address:
esxcfg-vmknic -l

Output will appear like this:

=========================================================================
[root@ESXTEST1 ~]# esxcfg-vmknic -l
Interface  Port Group/DVPort   IP Family IP Address                              Netmask         Broadcast       MAC Address       MTU     TSO MSS   Enabled Type
vmk0       VMkernel            IPv4      192.168.0.110                           255.255.255.0   192.168.0.255   00:50:56:78:7e:73 1500    65535     true    STATIC
vmk1       Vmotion             IPv4      192.168.0.77                            255.255.255.0   192.168.0.255   00:50:56:76:42:df 1500    65535     true    S
=========================================================================

5. To get the information about physical nics installed on ESX server
esxcfg-vmknic -l

Output will appear like this:
=========================================================================
[root@ESXTEST1 sbin]# esxcfg-nics -l
Name    PCI      Driver      Link Speed     Duplex MAC Address       MTU    Description
vmnic0  02:00.00 e1000       Up   1000Mbps  Full   00:0c:29:85:0d:76 1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic1  02:02.00 e1000       Up   1000Mbps  Full   00:0c:29:85:0d:80 1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic2  02:03.00 e1000       Up   1000Mbps  Full   00:0c:29:85:0d:8a 1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
vmnic3  02:04.00 e1000       Up   1000Mbps  Full   00:0c:29:85:0d:94 1500   Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)
=========================================================================

6. To add the new virtual switch named (vswitch3) to our ESX server.

[root@ESXTEST1 sbin]# esxcfg-vswitch -a vswitch3

Now vswitch3 is created without any port group.

======================================================================

Switch Name    Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vswitch3       64          1           64                1500

  PortGroup Name      VLAN ID  Used Ports  Uplinks
=========================================================================
7.To add the new port group  named (mgmt)to vswitch (vswitch 3):

[root@ESXTEST1 sbin]# esxcfg-vswitch -A mgmt vswitch3

now port group “mgmt” is added.

=========================================================================
Switch Name    Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vswitch3       64          1           64                1500

  PortGroup Name      VLAN ID  Used Ports  Uplinks
  mgmt                0        0
=========================================================================

8. To add the service console port (vswif2) to our newly created port group “mgmt” with the ip addr 192.168.0.79

[root@ESXTEST1 sbin]# esxcfg-vswif -a vswif2 -i 192.168.0.79 -n 255.255.255.0 -p “mgmt”

where i is the ip address, n is subnet mask p is to mentione the port group name
=========================================================================
vswif2   mgmt                IPv4      192.168.0.79                            255.255.255.0                           192.168.0.255    true      STATIC
=========================================================================
9.To add the vmkernal port (vmk2)  to our newly created port group “mgmt” with the ip addr 192.168.0.83

[root@ESXTEST1 sbin]# esxcfg-vmknic -a  -i 192.168.0.83 -n 255.255.255.0 -p “mgmt

=========================================================================
vmk2       mgmt                IPv4      192.168.0.83               255.255.255.0   192.168.0.255   00:50:56:7b:bd:36 1500    65535     true    STATIC
=========================================================================
10. To change the ip addresss of the existing service console “vswif2”.
nano /etc/sysconfig/network-scripts/ifcfg-vswif2.  

Edit the file with your new id address ” 192.168.0.255″ then save and exit.
======================================================
DEVICE=vswif2
HOTPLUG=yes
MACADDR=00:50:56:43:92:be
ONBOOT=yes
PORTGROUP=mgmt
BOOTPROTO=static
BROADCAST=192.168.0.255
DHCPV6C=no
IPADDR=192.168.0.96
IPV6INIT=no
IPV6_AUTOCONF=no
NETMASK=255.255.255.0
======================================================
restart the network service for ip change to take effect:

[root@ESXTEST1 sysconfig]# service network restart
Shutting down interface vswif0:                            [  OK  ]
Shutting down interface vswif2:                            [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface vswif0:                              [  OK  ]

Another way is to conncet to the console of the ESX server and at the shell prompt type in :esxcfg-vswif -d vswif2

This will delete the existing vswif0 and it will give the message about “nothing to flush”.

then type the below command

esxcfg-vswif -a vswif2 -p mgmt -i 192.168.0.97 -n 255.255.255.0
=========================================================================
[root@ESXTEST1 etc]# esxcfg-vswif -d vswif2
Nothing to flush.
[root@ESXTEST1 etc]# esxcfg-vswif -a vswif2 -p mgmt -i 192.168.0.97 -n 255.255.255.0
[2011-09-17 19:35:46 ‘Vnic’ warning] Generated New MAC address, 00:50:56:43:92:be for vswif2
Nothing to flush.
=========================================================================
11. To Edit the hostname and default gateway.

edit the below file:

nano  /etc/sysconfig/network
======================================
NETWORKING=yes
HOSTNAME=ESXTEST1.lab.com
GATEWAY=192.168.0.20
GATEWAYDEV=vswif0
IPV6_AUTOCONF=no
NETWORKING_IPV6=no
======================================
restart the network service for ip change to take effect:

[root@ESXTEST1 sysconfig]# service network restart

12.To edit the host file:

nano /etc/hosts

Edit the file to make entry to your host file.
==========================================
127.0.0.1       localhost
::1             localhost
192.168.0.75    ESXTEST1.lab.com ESXTEST1
==========================================

13. To edit the DNs entry of your ESX server

nano /etc/resolv.conf

Edit the file to make changes or to make new entry of dns for your ESX server
========================
nameserver 192.168.0.20
search lab.com
=======================

14.To query the firewall ports

esxcfg-firewall – q

15. to open the port in firewall  (port no 8877, tcp, incoming , name: test3

esxcfg-firewall -o 8877,tcp,in,test3

Exit mobile version