El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

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/ Troubleshooting/ Firewall Configuration Issues/ How Do I Disable a Linux ECS Firewall and Add a Port Exception on a Linux ECS Firewall?

How Do I Disable a Linux ECS Firewall and Add a Port Exception on a Linux ECS Firewall?

Updated on 2022-07-15 GMT+08:00

Scenarios

This section describes how to disable a Linux ECS firewall and add a port exception on a Linux ECS firewall.

CAUTION:

Enabling a firewall and configuring a security group protect your ECSs. If you disable a firewall, exercise caution when you enable ports in the security group.

Disabling a Firewall

Run the following command to disable the firewall based on the ECS OS:

  • CentOS 6

    service iptables stop

  • CentOS 7

    systemctl stop firewalld.service

  • Ubuntu

    ufw disable

  • Debian

    /etc/init.d/iptables stop

Adding a Port Exception on a Firewall

  • CentOS 6
    1. For example, to add TCP port 23, run the following command:

      iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT

    2. Save the configuration.

      service iptables save

    3. (Optional) Configure the firewall to automatically start upon ECS startup.
      chkconfig iptables on
      NOTE:
      • To disable automatic firewall startup, run the following command:

        chkconfig iptables off

      • When the firewall is started on CentOS 6, the "iptables no config file" error may be displayed because the iptables configuration file is not detected. To handle this issue, perform the following operations:
        1. Add a new rule.

          iptables -P OUTPUT ACCEPT

        2. Save the configuration.

          service iptables save

        3. Start the firewall again.

          service iptables start

  • CentOS 7
    1. Check the firewall status.

      systemctl status firewalld

      or

      firewall-cmd --state

    2. If the firewall is disabled, run the following command to enable it:

      systemctl start firewalld

      If "Failed to start firewalld.service: Unit is masked." is displayed, run the systemctl unmask firewalld command first and then run the preceding command again to enable the firewall:

    3. Run the following command to check whether the firewall is enabled:

      firewall-cmd --state

      Information similar to the following is displayed:

      [root@ecs-centos7 ~]# firewall-cmd --state
      running
    4. For example, to add TCP port 23, run the following command:

      firewall-cmd --zone=public --add-port=23/tcp --permanent

      The configuration is correct if the command output is as follows:

      [root@ecs-centos7 ~]# firewall-cmd --zone=public --add-port=23/tcp --permanent
      success
    5. Reload the policy configuration for the new configuration to take effect.

      firewall-cmd --reload

    6. View all enabled ports.

      firewall-cmd --list-ports

      [root@ecs-centos7 ~]# firewall-cmd --list-ports
      23/tcp
    7. (Optional) Configure the firewall to automatically start upon ECS startup.

      systemctl enable firewalld.service

      Check whether automatic firewall startup is enabled.

      systemctl is-enabled firewalld.service;echo $?

      The configuration is correct if the command output is as follows:

      [root@ecs-centos7 ~]# systemctl is-enabled firewalld.service;echo $?
      enabled
      0
      NOTE:

      To disable automatic firewall startup, run the following command:

      systemctl disable firewalld.service

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback