此内容的本地化语言页面暂未提供。我们将不断努力以提供本地化语言版本。感谢您的关注。

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/ Elastic Cloud Server/ User Guide (ME-Abu Dhabi Region)/ EIP/ Enabling Internet Connectivity for an ECS Without an EIP

Enabling Internet Connectivity for an ECS Without an EIP

Updated on 2024-07-24 GMT+08:00

Scenarios

To ensure platform security and conserve EIPs, EIPs are assigned only to specified ECSs. ECSs without EIPs cannot access the Internet directly. If these ECSs need to access the Internet (for example, to perform a software upgrade or install a patch), you can select an ECS with an EIP bound to function as a proxy ECS, providing an access channel for these ECSs.

NOTE:

NAT Gateway is recommended, which provides both the SNAT and DNAT functions for your ECSs in a VPC and allows the ECSs to access or provide services accessible from the Internet. For details, see NAT Gateway User Guide.

Prerequisites

  • A proxy ECS with an EIP bound is available.
  • The IP address of the proxy ECS is in the same network and same security group as the ECSs that need to access the Internet.

Linux Proxy ECS

In this example, the proxy ECS runs CentOS 6.5.

  1. Log in to the management console.
  2. Click in the upper left corner and select your region and project.
  3. Under Computing, click Elastic Cloud Server.
  4. In the search box above the upper right corner of the ECS list, enter the proxy ECS name for search.
  5. Click the name of the proxy ECS. The page providing details about the ECS is displayed.
  6. On the Network Interfaces tab, click . Then, disable Source/Destination Check.
    Figure 1 Disabling source/destination check

    By default, the source/destination check function is enabled. When this function is enabled, the system checks whether source IP addresses contained in the packets sent by ECSs are correct. If the IP addresses are incorrect, the system does not allow the ECSs to send the packets. This mechanism prevents packet spoofing, thereby improving system security. However, this mechanism prevents the packet sender from receiving returned packets. Therefore, disable the source/destination check.

  7. Log in to the proxy ECS.

    For more details, see Login Overview (Linux).

  8. Run the following command to check whether the proxy ECS can access the Internet:

    ping www.baidu.com

    The proxy ECS can access the Internet if information similar to the following is displayed:

    Figure 2 Checking connectivity
  9. Run the following command to check whether IP forwarding is enabled on the proxy ECS:

    cat /proc/sys/net/ipv4/ip_forward

    • If 0 (disabled) is displayed, go to 10.
    • If 1 (enabled) is displayed, go to 15.
  10. Run the following command to open the IP forwarding configuration file in the vi editor:

    vi /etc/sysctl.conf

  11. Press i to enter editing mode.
  12. Set the net.ipv4.ip_forward value to 1.

    Set the net.ipv4.ip_forward value to 1.

    NOTE:

    If the sysctl.conf file does not contain the net.ipv4.ip_forward parameter, run the following command to add it:

    echo net.ipv4.ip_forward=1 >> /etc/sysctl.conf

  13. Press Esc, type :wq, and press Enter.

    The system saves the configurations and exits the vi editor.

  14. Run the following command to make the modification take effect:

    sysctl -p /etc/sysctl.conf

  15. Run the following commands to configure default iptables rules:

    iptables -P INPUT ACCEPT

    iptables -P OUTPUT ACCEPT

    iptables -P FORWARD ACCEPT

    CAUTION:

    Running iptables -P INPUT ACCEPT will set default INPUT policy to ACCEPT, which poses security risks. You are advised to set security group rules to restrict inbound access.

  16. Run the following command to configure source network address translation (SNAT) to enable ECSs in the same network segment to access the Internet through the proxy ECS:

    iptables -t nat -A POSTROUTING -o eth0 -s subnet/netmask-bits -j SNAT --to nat-instance-ip

    For example, if the proxy ECS is in network 192.168.125.0, the subnet mask has 24 bits, and the private IP address is 192.168.125.4, run the following command:

    iptables -t nat -A POSTROUTING -o eth0 -s 192.168.125.0/24 -j SNAT --to 192.168.125.4

    NOTE:

    To retain the preceding configuration even after the ECS is restarted, run the vi /etc/rc.local command to edit the rc.local file. Specifically, copy the rule described in step 16 into rc.local, press Esc to exit Insert mode, and enter :wq to save the settings and exit.

  17. Run the following commands to save the iptables configuration and make it start up automatically upon ECS startup:

    service iptables save

    chkconfig iptables on

  18. Run the following command to check whether SNAT has been configured:

    iptables -t nat --list

    SNAT has been configured if information similar to Figure 3 is displayed.

    Figure 3 Successful SNAT configuration
  19. Add a route.
    1. Log in to the management console.
    2. Click in the upper left corner and select your region and project.
    3. Under Network, click Virtual Private Cloud.
    4. Choose Route Tables in the left navigation pane. In the route table list, click a target route table. On the displayed page, click Add Route.
    5. Set route information on the displayed page.
      • Destination: indicates the destination network segment. The default value is 0.0.0.0/0.
      • Next Hop: indicates the private IP address of the proxy ECS.

        You can obtain the private IP address of the ECS on the Elastic Cloud Server page.

  20. To delete the added iptables rules, run the following command:

    iptables -t nat -D POSTROUTING -o eth0 -s subnet/netmask-bits -j SNAT --to nat-instance-ip

    For example, if the proxy ECS is in network segment 192.168.125.0, the subnet mask has 24 bits, and the private IP address is 192.168.125.4, run the following command:

    iptables -t nat -D POSTROUTING -o eth0 -s 192.168.125.0/24 -j SNAT --to 192.168.125.4

我们使用cookie来确保您的高速浏览体验。继续浏览本站,即表示您同意我们使用cookie。 详情

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback