CentOS7 Firewall常用命令彙總

2021-10-07 17:01:25 字數 2532 閱讀 5196

參考:

1. 首先不能關防火牆

systemctl enable firewalld

systemctl restart firewalld

systemctl status firewalld

2. 永久開放埠訪問

firewall-cmd --permanent --add-port=80/tcp

firewall-cmd --permanent --add-port=443/tcp

firewall-cmd --permanent --add-port=18080/tcp

firewall-cmd --permanent --add-port=10128/tcp

firewall-cmd --permanent --add-port=10129/tcp

firewall-cmd --permanent --add-port=10130/tcp

firewall-cmd --permanent --add-port=10131/tcp

firewall-cmd --permanent --add-port=10080/tcp

firewall-cmd --permanent --add-port=19229/tcp

firewall-cmd --permanent --add-port=19339/tcp

3. 新增埠**

firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toport=9091

將 本地伺服器 3000 埠的內容 通過 80 埠暴露出來 提供服務

firewall-cmd --permanent --add-forward-port=port=443:proto=tcp:toport=9443

將 本地伺服器 9443 埠的內容 通過 443 埠暴露出來 提供服務

4. 重新reload

firewall-cmd --reload

systemctl status firewalld

firewall-cmd --list-all 

[root@erpbackup sbin]# systemctl status firewalld 

● firewalld.service - firewalld - dynamic firewall daemon

loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: disabled)

active: active (running) since 四 2020-07-02 15:39:31 cst; 3min 46s ago

docs: man:firewalld(1)

main pid: 3196 (firewalld)

cgroup: /system.slice/firewalld.service

└─3196 /usr/bin/python2 -es /usr/sbin/firewalld --nofork --nopid

7月 02 15:39:31 erpbackup systemd[1]: stopped firewalld - dynamic firewall daemon.

7月 02 15:39:31 erpbackup systemd[1]: starting firewalld - dynamic firewall daemon...

7月 02 15:39:31 erpbackup systemd[1]: started firewalld - dynamic firewall daemon.

[root@erpbackup sbin]# firewall-cmd --list-all

public

target: default

icmp-block-inversion: no

inte***ces:

sources:

services: dhcpv6-client ssh

ports: 80/tcp 443/tcp 18080/tcp 10128/tcp 10129/tcp 10130/tcp 10131/tcp

protocols:

masquerade: no

forward-ports: port=80:proto=tcp:toport=9091:toaddr=

port=443:proto=tcp:toport=9443:toaddr=

source-ports:

icmp-blocks:

rich rules:

[root@erpbackup sbin]#

參考:

1、firewalld的基本使用

啟動: systemctl start firewalld

檢視狀態: systemctl status firewalld 

停止: systemctl disable firewalld

禁用: systemctl stop firewalld

centos 7 firewall無法啟動

報錯資訊 root localhost bin systemctl status firewalld firewalld.service firewalld dynamic firewall daemon loaded loaded usr lib systemd system firewalld....

CentOS 7 firewall使用方法

1.在firewall規則中新增80埠 firewall cmd zone public add port 80 tcp permanent 2.獲取firewall狀態資訊 firewall cmd state firewall cmd reload 不改變狀態 firewall cmd comp...

centos7 firewall指定IP與埠訪問

1 啟動防火牆 systemctl start firewalld.service 2 指定ip與埠 firewall cmd permanent add rich rule rule family ipv4 source address 192.168.142.166 port protocol ...