CentOS 7 防火墙firewalld 打开端口指令范例

查看服务状态/刷新规则使生效:

systemctl status firewalld / service firewalld restart
firewall-cmd --reload

 

永久打开端口:

firewall-cmd --add-port=8080/tcp --permanent
firewall-cmd --add-port=5000-5100/tcp --permanent
firewall-cmd --add-port={110/tcp,143/tcp} --permanent
firewall-cmd --add-service=smtp --permanent
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="127.0.0.1" port protocol="tcp" port="8000" accept"
#对指定远程IP地址127.0.0.1打开8000端口

 

永久禁止:

firewall-cmd --permanent --add-rich-rule="rule family=ipv4 source address='x.x.x.x/24' service name='ssh' drop"

 

列出所有的內容:

firewall-cmd --list-all-zones
firewall-cmd --list-all

 

永久删除HTTP服务端口:

firewall-cmd --zone=public --permanent --remove-service=http
firewall-cmd --zone=public --permanent --remove-port=80/tcp
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="127.0.0.1" port protocol="tcp" port="8000" accept"

 

端口转发:

firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toport=8080:toaddr=192.0.2.55
firewall-cmd --permanent --add-masquerade

转发和伪装(需要转发的网卡wg0,ip:10.200.200.1):

firewall-cmd --permanent --direct --add-rule ipv4 filter FORWARD 0 -i wg0 -o eth0 -j ACCEPT
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.200.200.1/24 masquerade'
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇