ESX 命令行下配置网络信息

上一篇 / 下一篇  2011-09-04 13:01:27 / 个人分类:ESX\

Configuring networking from the ESX service console command line

come from:http://kb.vmware.com/kb/1003796

To configure networking from the ESX service console command line:
  1. 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:

    NamePCIDriverLink SpeedDuplex Description
    vmnic006:00.00 tg3Up1000Mbps FullBroadcom Corporation NetXtreme BCM5721 Gigabit Ethernet
    vmnic107:00.00 tg3Up1000Mbps FullBroadcom Corporation NetXtreme BCM5721 Gigabit Ethernet

    In the Link column,Upindicates that the network adapter is available and functioning.
  1. List the current virtual switches with the command:

    [root@server root]# esxcfg-vswitch –l

    The output appears similar to:

    Switch NameNum PortsUsed PortsConfigured PortsUplinks
    vSwitch032332vmnic0

    PortGroup NameInternal IDVLAN IDUsed PortsUplinks
    VM Networkportgroup200vmnic0

    In the example output, there exists a virtual machine network namedVM Networkwith 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.

  2. Create a new virtual switch with the command:

    [root@server root]
    # esxcfg-vswitch –a vSwitch1

  3. 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, seeRecreating Service Console Networking from the command line (1000266).

  4. Up-link vmnic1 to the new virtual switch with the command:

    [root@server root]# esxcfg-vswitch –L vmnic1 vSwitch1

  5. If you need to assign a VLAN, use the command:

    [root@server root]# esxcfg-vswitch -v <VLAN> -p “Service Console” vSwitch0

    where<VLANID>is the VLAN number. A zero here specifies no VLAN.

  6. Verify the new virtual switch configuration with the command:

    [root@server root]#esxcfg-vswitch –l

    The output appears similar to:

    Switch NameNum PortsUsed PortsConfigured PortsUplinks
    vSwitch032332vmnic0

    PortGroup NameInternal IDVLAN IDUsed PortsUplinks
    Service Consoleportgroup501vmnic0

    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

  7. 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.

  8. Verify the configuration with the command:

    [root@esx]# esxcfg-vswif –l
    NamePort GroupIP AddressNetmaskBroadcastEnabledDHCP
    v
    swif0Service Console192.168.1.10255.255.255.0192.168.1.255truefalse

  9. Verify the networking configuration on the ESX host. SeeVerifying ESX host networking configuration on the service console (1003796).

*****************************************************************************************************************************

Changing the IP address, default gateway, and hostname of the Service Console in ESX

Changing settings from the physical or remote console connection
 
Changing the IP for the Service Console must be done from the physical console or through a remote console session. If you make changes through a network connection such as SSH, network connectivity to the Service Console disconnects because the Service Console's network interface changes.
  1. Run this command to set the IP address:

    [root@server root]# esxcfg-vswif -i <a.b.c.d> -n <w.x.y.z> vswif0, where<a.b.c.d>is the IP address and<w.x.y.z>is the subnet mask.

    Note: In this example,vswif0is the Service Console adapter that is the interface to which you are applying the IP address change.

  2. Open the/etc/hostsfile with a text editor and modify it so that it reflects the correct IP address and hostname.
  3. To change the default gateway address and the hostname, edit the/etc/sysconfig/networkfile and change the GATEWAY and HOSTNAME parameters to the proper values.
  4. For the changes to take place, reboot the host or restart the network service with the command:

    [root@server root]#service network restart

    Note: This command breaks any current network connections to the Service Console, but virtual machines continue to have network connection. If the ESX host is managed by VirtualCenter or vCenter Server, you may have to remove and re-add the host to the inventory. For more information, seeESX not working properly in VirtualCenter after IP address change (1005633).
Note: If the changed IP does not persist across a reboot, try deleting and recreating the Service Console vswif management interface. For more information, seeRecreating Service Console networking from the command line (1000266).
******************************************************************************************************************************

Verifying ESX host networking configuration on the service console

  1. To verify the format and content of /etc/hosts, run the command:

    [root@server root]# cat /etc/hosts

    Here is an example of the hostsfile:

    127.0.0.1       localhost.localdomain localhost
    192.168.1.10    server.domain.com server

  2. To verify the contents of/etc/sysconfig/network, run the command:

    [root@server root]# cat /etc/sysconfig/network

    Confirm that the proper values for your environment exist for the fully qualified hostname and gateway. Consult your network administrator if you are unsure of the proper values.

    Here is an example of thenetworkfile:

    NETWORKING=yes
    HOSTNAME=server.domain.com
    GATEWAY=192.168.1.1
    GATEWAYDEV=vswif0

  3. To verify that /etc/sysconfig/network-scripts/ifcfg-vswif0has the correct settings for IP address (IPADDR), subnet mask (NETMASK), and network (NETWORK), run the command:

    [root@server root]# cat /etc/sysconfig/network-scripts/ifcfg-vswif0

    Consult your network administrator if you are unsure of the correct settings.

    Here is an example of the ifcfg-vswif0file:

    DEVICE=vswif0
    BOOTPROTO=static
    BROADCAST=192.168.1.255
    IPADDR=192.168.1.10
    NETMASK=255.255.255.0
    NETWORK=192.168.1.0
    ONBOOT=yes
    PORTGROUP="Service Console"
    MACADDR=00:50:56:4a:66:ba

  4. To display the routing table, run the command:

    [root@server root]# route –n

    The output looks similar to:

    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 vswif0
    169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 vswif0
    0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 vswif0

    Ensure that the second column of the row flagged with UG matches the gateway address for your environment.

  5. To verify that the DNS information in/etc/resolv.confis correct for your environment, run the command:

    [root@server root]# /etc/resolv.conf

    Here is an example of theresolv.conffile:

    search domain.com
    nameserver 192.168.1.2
    nameserver 192.168.1.3

    Note: By default, up to three nameservers can be added toresolv.conf. The compile time parameterMAXNSdefines how many nameservers can be used.
     
  6. Verify network connectivity between systems. For more information, see Testing network connectivity with the Ping command (1003486).
     
Note: Changes to thenetworkandifcfg-vswif0files require a restart of the network service. To restart the network service, run the following command and pressEnter:
 
[root@server root]# service network restart
*****************************************************************************************************************************

Recreating Service Console networking from the command line

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. 
  1. Run the following command to list the name of the vswif adapter:

    esxcfg-vswif -l

  2. Run the following command to delete the vswif adapter:

    esxcfg-vswif --del vswif0

  3. Run the following command tolist the name of the vSwitch:

    esxcfg-vswitch -l

  4. Run the following command to delete the vSwitch:

    esxcfg-vswitch -d vSwitch0

  5. Run the following command to create the vSwitch:

    esxcfg-vswitch -a vSwitch0

  6. Run the following commands to create default port groups for vSwitch:

    esxcfg-vswitch -A "VM Network" vSwitch0
    esxcfg-vswitch -A "Service Console" vSwitch0

  7. 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 

  8. 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

  9. 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

  10. Run the following command to verify that the vmnic is associated with the vSwitch:

    esxcfg-vswitch -l

  11. 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

  12. Run the following command to change the vlan ID of a vSwitch:

    [root@server root]# esxcfg-vswitch -p "VM Network 1" -v 10 vSwitch0


  13. If you make any manual changes to/etc/sysconfig/network, run the following command to restart the network service:

    service network restart

TAG: configuration IP

 

评分:0

我来说两句

我的栏目

日历

« 2024-04-29  
 123456
78910111213
14151617181920
21222324252627
282930    

我的存档

数据统计

  • 访问量: 1870
  • 日志数: 1
  • 建立时间: 2011-09-04
  • 更新时间: 2011-09-04

RSS订阅

Open Toolbar