Centos7 Firewall configuration application instance reference

Source: Internet
Author: User

Centos7 Firewall configuration application instance reference

For simple configuration, refer to learning:

-- When permanent is set to permanent, add this parameter at the beginning or end of the command. Otherwise, the setting becomes invalid after the firewall is reloaded or restarted!

Open Port:

# Firewall-cmd -- zone = public -- add-port = 80/tcp -- permanent

# Firewall-cmd -- zone = public -- add-port = 22/tcp -- permanent

You can specify multiple At A Time:

# Firewall-cmd -- zone = public -- permanent -- add-port = 111/tcp -- add-port = 139/tcp -- add-port = 445/tcp

Firewall-cmd -- reload

View All opened ports:

# Firewall-cmd -- list-port

# Firewall-cmd -- zone = public -- list-ports

Enable disguise:

# Firewall-cmd [-- zone = zone] -- add-masquerade

# Firewall-cmd -- remove-masquerade

# Firewall-cmd -- query-masquerade

Add region interface:

# Firewall-cmd [-- zone = zone] -- add-interface = <interface>

# Firewall-cmd -- zone = public -- add-interface = eth0

List features of all enabled regions

Firewall-cmd -- list-all-zones

All features enabled in the output zone <zone>. If the region is omitted, information about the default region is displayed.

# Firewall-cmd -- zone = public -- list-all

Enable a service:

Firewall-cmd -- add-service = http

Firewall-cmd -- add-service = vnc-server

# Firewall-cmd -- zone = public -- add-service = nfs -- add-service = samba-client -- permanent

Firewall-cmd -- remove-service = service remove a service

Query: firewall-cmd -- list-service

NAT address translation:

Firewall-cmd [-- zone = <zone>] -- add-forward-port = <port> [-<port>]: proto = <protocol> {: toport = <port> [-<port>] |: toaddr = <address> |: toport = <port> [-<port>]: toaddr = <address>}

IP port forwarding:

# Firewall-cmd -- add-forward-port = 222: proto = tcp: toport = 333: toaddr = 192.168.1.100

Local forwarding:

# Firewall-cmd -- add-forward-port = 9898: proto = tcp: toport = 8088: toaddr =

Success

Query:

# Firewall-cmd -- list-forward-port

# Firewall-cmd -- list-port

# Firewall-cmd -- list-all

Remove:

# Firewall-cmd -- remove-forward-port = 222: proto = tcp: toport = 333: toaddr =

# Firewall-cmd -- remove-forward-port = 222: proto = tcp: toport = 333: toaddr = 192.168.1.100

Graphical Configuration tool: # firewall-config

Custom rules:

/Sbin/iptables-t filter-I INPUT_direct 2-s 192.168.1.1-p tcp -- dport = 22-j DROP

Usage: -- direct -- add-rule {ipv4 | ipv6 | eb} <table> <chain> <priority> <args>

# Firewall-cmd -- permanent -- direct -- add-rule ipv4 filter INPUT 1-s 192.168.1.0/24-p tcp -- dport = 22-j ACCEPT

# Firewall-cmd -- permanent -- direct -- add-rule ipv4 filter INPUT 2-p tcp -- dport = 22-j DROP

# Firewall-cmd -- reload

# Firewall-cmd -- direct -- get-all-rules

Ipv4 filter INPUT 1-s 192.168.1.0/24-p tcp -- dport = 22-j ACCEPT

Ipv4 filter INPUT 2-p tcp -- dport = 22-j DROP

Official reference

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.