Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Virtual Private Cloud/ User Guide/ Virtual IP Address/ Binding a Virtual IP Address to an Instance or EIP

Binding a Virtual IP Address to an Instance or EIP

Updated on 2025-01-17 GMT+08:00

Scenarios

You can bind a virtual IP address to an instance or EIP. An instance can be a cloud server, a network interface, or a Layer 2 connection.
  • Bind a virtual IP address to an instance. You can:
    • Bind one or more virtual IP addresses to an instance.
    • Bind a virtual IP address to multiple instances.
  • Bind a virtual IP address to an EIP to enable public network communication.

Constraints

It is recommended that a maximum of eight virtual IP addresses be bound to an ECS. If an ECS has multiple virtual IP addresses, each virtual IP address is used by a specific service. If there are too many services, the ECS may become overloaded and compromise user experience.

Binding a Virtual IP Address to an EIP or ECS on the Console

  1. Log in to the management console.
  2. Click in the upper left corner and select the desired region and project.
  3. Click in the upper left corner and choose Networking > Virtual Private Cloud.

    The Virtual Private Cloud page is displayed.

  4. In the navigation pane on the left, choose Virtual Private Cloud > Subnets.

    The Subnets page is displayed.

  5. In the subnet list, locate the target subnet and click its name.

    The subnet details page is displayed.

  6. On the IP Addresses tab, bind an EIP to the virtual IP address:
    1. Locate the row that contains the virtual IP address and click Bind to EIP in the Operation column.

      The Bind to EIP dialog box is displayed.

    2. Select an EIP and click OK.

      In the virtual IP address list, you can view the bound EIP.

  7. On the IP Addresses tab, bind an instance to the virtual IP address:
    1. Locate the row that contains the virtual IP address and click Bind to Instance in the Operation column.

      The Bind to Instance dialog box is displayed.

    2. Select an instance and click OK.

      In the virtual IP address list, you can view the bound instance.

      NOTICE:

Configuring a Virtual IP Address for an ECS

After you bind one or more virtual IP addresses to an ECS on the console, you must log in to the ECS to manually configure these virtual IP address.

The following OSs are used as examples here. For other OSs, see the help documents on their official websites.
  • Linux: CentOS 7.2 64bit and Ubuntu 22.04 server 64bit
  • Windows: Windows Server
The following uses CentOS 7.2 64bit as an example.
  1. Obtain the network interface that the virtual IP address is to be bound and the connection of the network interface:

    nmcli connection

    Information similar to the following is displayed:

    The command output in this example is described as follows:

    • eth0 in the DEVICE column indicates the network interface that the virtual IP address is to be bound.
    • Wired connection 1 in the NAME column indicates the connection of the network interface.
  2. Add the virtual IP address for the connection:

    nmcli connection modify "<connection-name-of-the-network-interface>" +ipv4.addresses <virtual-IP-address>

    Configure the parameters as follows:

    • connection-name-of-the-network-interface: The connection name of the network interface obtained in 1. In this example, the connection name is Wired connection 1.
    • virtual-IP-address: Enter the virtual IP address to be added. If you add multiple virtual IP addresses at a time, separate every two with a comma (,).
    Example commands:
    • Adding a single virtual IP address: nmcli connection modify "Wired connection 1" +ipv4.addresses 172.16.0.125
    • Adding multiple virtual IP addresses: nmcli connection modify "Wired connection 1" +ipv4.addresses 172.16.0.125,172.16.0.126
  3. Make the configuration in 2 take effect:

    nmcli connection up "<connection-name-of-the-network-interface>"

    In this example, run the following command:

    nmcli connection up "Wired connection 1"

    Information similar to the following is displayed:

  4. Check whether the virtual IP address has been bound:

    ip a

    Information similar to the following is displayed. In the command output, the virtual IP address 172.16.0.125, is bound to network interface eth0.

    NOTE:

    To delete an added virtual IP address, perform the following steps:

    1. Delete the virtual IP address from the connection of the network interface:

      nmcli connection modify "<connection-name-of-the-network-interface>" -ipv4.addresses <virtual-IP-address>

      To delete multiple virtual IP addresses at a time, separate every two with a comma (,). Example commands are as follows:
      • Deleting a single virtual IP address: nmcli connection modify "Wired connection 1" -ipv4.addresses 172.16.0.125
      • Deleting multiple virtual IP addresses: nmcli connection modify "Wired connection 1" -ipv4.addresses 172.16.0.125,172.16.0.126
    2. Make the deletion take effect by referring to 3.
The following uses Ubuntu 22.04 server 64bit as an example. If the ECS runs Ubuntu 22 or Ubuntu 20, perform the following operations:
  1. Obtain the network interface that the virtual IP address is to be bound:

    ifconfig

    Information similar to the following is displayed. In this example, the network interface bound to the virtual IP address is eth0.
    root@ecs-X-ubantu:~# ifconfig
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 172.16.0.210  netmask 255.255.255.0  broadcast 172.16.0.255
            inet6 fe80::f816:3eff:fe01:f1c3  prefixlen 64  scopeid 0x20<link>
            ether fa:16:3e:01:f1:c3  txqueuelen 1000  (Ethernet)
            RX packets 43915  bytes 63606486 (63.6 MB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 3364  bytes 455617 (455.6 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    ...
  2. Switch to the /etc/netplan directory:

    cd /etc/netplan

  3. Add a virtual IP address to the network interface.
    1. Open the configuration file 01-netcfg.yaml:

      vim 01-netcfg.yaml

    2. Press i to enter the editing mode.
    3. In the network interface configuration area, add a virtual IP address.

      In this example, add a virtual IP address for eth0:

      addresses:

      - 172.16.0.26/32

      The file content is as follows:
      network:
          version: 2
          renderer: NetworkManager
          ethernets:
              eth0:
                  dhcp4: true
                  addresses:
                  - 172.16.0.26/32
              eth1:
                  dhcp4: true
              eth2:
                  dhcp4: true
              eth3:
                  dhcp4: true
              eth4:
                  dhcp4: true
    4. Press Esc, enter :wq!, save the configuration, and exit.
  4. Make the configuration in 3 take effect:

    netplan apply

  5. Check whether the virtual IP address has been bound:

    ip a

    Information similar to the following is displayed. In the command output, virtual IP address 172.16.0.26 is bound to network interface eth0.
    root@ecs-X-ubantu:/etc/netplan# ip a
    ...
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether fa:16:3e:01:f1:c3 brd ff:ff:ff:ff:ff:ff
        altname enp0s3
        altname ens3
        inet 172.16.0.26/32 scope global noprefixroute eth0
           valid_lft forever preferred_lft forever
        inet 172.16.0.210/24 brd 172.16.0.255 scope global dynamic noprefixroute eth0
           valid_lft 107999971sec preferred_lft 107999971sec
        inet6 fe80::f816:3eff:fe01:f1c3/64 scope link 
           valid_lft forever preferred_lft forever
    NOTE:

    To delete an added virtual IP address, perform the following steps:

    1. Open the configuration file 01-netcfg.yaml and delete the virtual IP address of the corresponding network interface by referring to 3.
    2. Make the deletion take effect by referring to 4.

The following operations use Windows Server as an example.

  1. In Control Panel, click Network and Sharing Center, and click the corresponding local connection.
  2. On the displayed page, click Properties.
  3. On the Network tab page, select Internet Protocol Version 4 (TCP/IPv4).
  4. Click Properties.
  5. Select Use the following IP address and set IP address to the private IP address of the ECS, for example, 10.0.0.101.
    Figure 1 Configuring private IP address
  6. Click Advanced.
  7. On the IP Settings tab, click Add in the IP addresses area.

    Add the virtual IP address, for example, 10.0.0.154.

    Figure 2 Configuring virtual IP address
  8. Click OK.
  9. In the Start menu, open the Windows command line window and run the following command to check whether the virtual IP address has been configured:

    ipconfig /all

    In the command output, IPv4 Address is the virtual IP address 10.0.0.154, indicating that the virtual IP address of the ECS's network interface has been correctly configured.

The following uses CentOS 7.2 64bit as an example.
  1. Obtain the network interface that the virtual IP address is to be bound and the connection of the network interface:

    nmcli connection

    Information similar to the following is displayed:

    The command output in this example is described as follows:

    • eth0 in the DEVICE column indicates the network interface that the virtual IP address is to be bound.
    • Wired connection 1 in the NAME column indicates the connection of the network interface.
  2. Add the virtual IP address for the connection:

    nmcli connection modify "<connection-name-of-the-network-interface>" +ipv4.addresses <virtual-IP-address>

    Configure the parameters as follows:

    • connection-name-of-the-network-interface: The connection name of the network interface obtained in 1. In this example, the connection name is Wired connection 1.
    • virtual-IP-address: Enter the virtual IP address to be added. If you add multiple virtual IP addresses at a time, separate every two with a comma (,).
    Example commands:
    • Adding a single virtual IP address: nmcli connection modify "Wired connection 1" +ipv4.addresses 172.16.0.125
    • Adding multiple virtual IP addresses: nmcli connection modify "Wired connection 1" +ipv4.addresses 172.16.0.125,172.16.0.126
  3. Make the configuration in 2 take effect:

    nmcli connection up "<connection-name-of-the-network-interface>"

    In this example, run the following command:

    nmcli connection up "Wired connection 1"

    Information similar to the following is displayed:

  4. Check whether the virtual IP address has been bound:

    ip a

    Information similar to the following is displayed. In the command output, the virtual IP address 172.16.0.125, is bound to network interface eth0.

    NOTE:

    To delete an added virtual IP address, perform the following steps:

    1. Delete the virtual IP address from the connection of the network interface:

      nmcli connection modify "<connection-name-of-the-network-interface>" -ipv4.addresses <virtual-IP-address>

      To delete multiple virtual IP addresses at a time, separate every two with a comma (,). Example commands are as follows:
      • Deleting a single virtual IP address: nmcli connection modify "Wired connection 1" -ipv4.addresses 172.16.0.125
      • Deleting multiple virtual IP addresses: nmcli connection modify "Wired connection 1" -ipv4.addresses 172.16.0.125,172.16.0.126
    2. Make the deletion take effect by referring to 3.
The following uses Ubuntu 22.04 server 64bit as an example. If the ECS runs Ubuntu 22 or Ubuntu 20, perform the following operations:
  1. Obtain the network interface that the virtual IP address is to be bound:

    ifconfig

    Information similar to the following is displayed. In this example, the network interface bound to the virtual IP address is eth0.
    root@ecs-X-ubantu:~# ifconfig
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 172.16.0.210  netmask 255.255.255.0  broadcast 172.16.0.255
            inet6 fe80::f816:3eff:fe01:f1c3  prefixlen 64  scopeid 0x20<link>
            ether fa:16:3e:01:f1:c3  txqueuelen 1000  (Ethernet)
            RX packets 43915  bytes 63606486 (63.6 MB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 3364  bytes 455617 (455.6 KB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    ...
  2. Switch to the /etc/netplan directory:

    cd /etc/netplan

  3. Add a virtual IP address to the network interface.
    1. Open the configuration file 01-netcfg.yaml:

      vim 01-netcfg.yaml

    2. Press i to enter the editing mode.
    3. In the network interface configuration area, add a virtual IP address.

      In this example, add a virtual IP address for eth0:

      addresses:

      - 172.16.0.26/32

      The file content is as follows:
      network:
          version: 2
          renderer: NetworkManager
          ethernets:
              eth0:
                  dhcp4: true
                  addresses:
                  - 172.16.0.26/32
              eth1:
                  dhcp4: true
              eth2:
                  dhcp4: true
              eth3:
                  dhcp4: true
              eth4:
                  dhcp4: true
    4. Press Esc, enter :wq!, save the configuration, and exit.
  4. Make the configuration in 3 take effect:

    netplan apply

  5. Check whether the virtual IP address has been bound:

    ip a

    Information similar to the following is displayed. In the command output, virtual IP address 172.16.0.26 is bound to network interface eth0.
    root@ecs-X-ubantu:/etc/netplan# ip a
    ...
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether fa:16:3e:01:f1:c3 brd ff:ff:ff:ff:ff:ff
        altname enp0s3
        altname ens3
        inet 172.16.0.26/32 scope global noprefixroute eth0
           valid_lft forever preferred_lft forever
        inet 172.16.0.210/24 brd 172.16.0.255 scope global dynamic noprefixroute eth0
           valid_lft 107999971sec preferred_lft 107999971sec
        inet6 fe80::f816:3eff:fe01:f1c3/64 scope link 
           valid_lft forever preferred_lft forever
    NOTE:

    To delete an added virtual IP address, perform the following steps:

    1. Open the configuration file 01-netcfg.yaml and delete the virtual IP address of the corresponding network interface by referring to 3.
    2. Make the deletion take effect by referring to 4.

The following operations use Windows Server as an example.

  1. In Control Panel, click Network and Sharing Center, and click the corresponding local connection.
  2. On the displayed page, click Properties.
  3. On the Network tab page, select Internet Protocol Version 4 (TCP/IPv4).
  4. Click Properties.
  5. Select Use the following IP address and set IP address to the private IP address of the ECS, for example, 10.0.0.101.
    Figure 1 Configuring private IP address
  6. Click Advanced.
  7. On the IP Settings tab, click Add in the IP addresses area.

    Add the virtual IP address, for example, 10.0.0.154.

    Figure 2 Configuring virtual IP address
  8. Click OK.
  9. In the Start menu, open the Windows command line window and run the following command to check whether the virtual IP address has been configured:

    ipconfig /all

    In the command output, IPv4 Address is the virtual IP address 10.0.0.154, indicating that the virtual IP address of the ECS's network interface has been correctly configured.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback