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

Using DNAT to Access a Kafka Instance

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

Scenario

You can use destination NAT (DNAT) to access a Kafka instance so that the instance can provide services on the public network through port mapping.

Prerequisites

You have created EIPs. The number of EIPs is the same as the number of brokers in the Kafka instance.

Step 1: Obtain Information About the Kafka Instance

  1. Log in to the management console.
  2. Click in the upper left corner to select a region.

    NOTE:

    Select the region where your Kafka instance is located.

  3. Click in the upper left corner and choose Application > Distributed Message Service for Kafka to open the console of DMS for Kafka.
  4. Click the desired Kafka instance to view the instance details.
  5. In the Connection area on the Basic Information tab page, view and record the private network access addresses of the Kafka instance. In the Network area, view and record the VPC and subnet where the Kafka instance is located.

    Figure 1 Kafka instance information

Step 2: Create a Public NAT Gateway

  1. Click in the upper left corner of the management console and choose Network > NAT Gateway. The Public NAT Gateways page is displayed.
  2. Click Create Public NAT Gateway.
  3. Set the following parameters:

    • Region: Select the region that the Kafka instance is in.
    • Name: Enter a name for the public NAT gateway.
    • VPC: Select the VPC recorded in 5.
    • Subnet: Select the subnet recorded in 5.

    Set other parameters as required. For details, see Creating a Public NAT Gateway.

    Figure 2 Creating a public NAT gateway

  4. Click Create Now.
  5. Confirm the specifications and click Submit.

Step 3: Add a DNAT Rule

  1. On Public NAT Gateways page, locate the row that contains the newly created public NAT gateway and click Configure Rules in the Operation column.
  2. On the DNAT Rules tab page, click Add DNAT Rule.

    Figure 3 Public NAT gateway details

  3. Set the following parameters:

    • Scenario: Select VPC.
    • Port Type: Select Specific port.
    • Protocol: Select TCP.
    • EIP: Select an EIP.
    • Outside Port: Enter 9011.
    • Instance Type: Select Custom.
    • Private IP Address: Enter one of the private network addresses of the Kafka instance recorded in 5.
    • Inside Port: Enter 9011.

    For details about more parameters, see Adding a DNAT Rule.

    Figure 4 Adding a DNAT rule

  4. Click OK.

    View the DNAT rule status in the DNAT rule list. If Status is Running, the rule has been added successfully.

  5. Create DNAT rules for other private network addresses of the Kafka instance recorded in 5. Configure a unique EIP for each DNAT rule.

    For details about how to create a DNAT rule, see 2 to 4.

  6. After all DNAT rules are created, click the DNAT Rules tab to view the created DNAT rules and record the EIPs corresponding to the private IP addresses.

    Figure 5 DNAT rule list

Step 4: Bind EIPs on the Kafka Console

  1. Click in the upper left corner and choose Application > Distributed Message Service for Kafka to open the console of DMS for Kafka.
  2. Click the desired Kafka instance to view the instance details.
  3. In the Advanced Settings section on the Basic Information tab page, click Modify next to Cross-VPC Access.
  4. Change the values of advertised.listeners IP Address/Domain Name to the EIPs in the DNAT rules. Ensure that the mapping between the private network addresses and the EIPs is consistent with that recorded in 6. Then click Save.

    Figure 6 Changing the advertised.listeners IP address (for DNAT access)

Step 5: Verify Connectivity

Check whether messages can be created and retrieved by referring to Accessing a Kafka Instance Without SASL or Accessing a Kafka Instance with SASL.

Notes:

  • The address for connecting to a Kafka instance is in the format of "advertised.listeners IP:9011". For example, the addresses for connecting to the Kafka instance shown in Figure 6 are 9.xxx.xxx.11:9011,9.xxx.xxx.12:9011,9.xxx.xxx.13:9011.
  • Configure security group rules for the Kafka instance to allow inbound access over port 9011.
  • Public access must be enabled on the client connected to the Kafka instance.

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