Linux下防火牆開啟相關埠及檢視已開啟埠
Linux下防火牆開啟相關埠及檢視已開啟埠
1. 預設情況下Linux的防火牆都是在關閉狀態下的
[root@test etc]# service iptables status
Firewall is stopped.
[root@test etc]#
2. 防火牆開通的情況
[root@test ~]# service iptables start
iptables: Applying firewall rules: [ OK ]
[root@test ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
[root@test ~]#
以上可以看出,防火牆開通的埠為22 state NEW tcp dpt:22
還有其他一些狀態資訊
3. 開通特定埠,比如tcp 80 和 5666埠
[root@test ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
4. 儲存並重啟防火牆
[root@test ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
[root@test ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
[root@test ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
埠80 已開通。同樣的方式開通5666埠
1. 預設情況下Linux的防火牆都是在關閉狀態下的
[root@test etc]# service iptables status
Firewall is stopped.
[root@test etc]#
2. 防火牆開通的情況
[root@test ~]# service iptables start
iptables: Applying firewall rules: [ OK ]
[root@test ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
2 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
3 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
5 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
[root@test ~]#
以上可以看出,防火牆開通的埠為22 state NEW tcp dpt:22
還有其他一些狀態資訊
3. 開通特定埠,比如tcp 80 和 5666埠
[root@test ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
4. 儲存並重啟防火牆
[root@test ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
[root@test ~]# service iptables restart
iptables: Flushing firewall rules: [ OK ]
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
[root@test ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
2 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
4 ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
6 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
1 REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
埠80 已開通。同樣的方式開通5666埠
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1337181/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ubuntu下開啟/關閉防火牆 及埠 - 命令Ubuntu防火牆
- linux下修改防火牆,開啟8080埠Linux防火牆
- CentOS開啟防火牆及開放指定埠CentOS防火牆
- 開啟、關閉防火牆或者開放埠防火牆
- linux下mysql開啟遠端訪問許可權及防火牆開放3306埠LinuxMySql訪問許可權防火牆
- CentOS7使用firewalld開啟關閉防火牆與埠CentOS防火牆
- Linux中如何檢視開啟了哪些埠?Linux
- CentOS8檢視防火牆狀態,開啟/關閉防火牆CentOS防火牆
- linux 防火牆埠號開發情況Linux防火牆
- Linux系統下如何在防火牆開放指定埠Linux防火牆
- linux關閉防火牆命令 linux防火牆關閉和開啟命令Linux防火牆
- 如何檢視遠端埠是否開啟
- CentOS 7 開放防火牆埠CentOS防火牆
- Linux 7新增防火牆埠Linux防火牆
- Linux 中如何開啟埠Linux
- centos7怎麼檢視、開啟和關閉防火牆CentOS防火牆
- Linux開啟hadoop沒有開啟9000埠LinuxHadoop
- linux系統檢視防火牆是否開啟並清除防火牆規則的方法步驟Linux防火牆
- CentOS7檢視開放埠命令、檢視埠占用情況和開啟埠命令、殺掉程式等命令教程。CentOS
- linux下3種檢測遠端埠是否開啟的方法Linux
- Linux檢視啟動的服務的埠Linux
- centos7開放、關閉及檢視埠CentOS
- CentOS7檢視開放埠命令及開放埠號CentOS
- Linux 檢視對外開放埠Linux
- linux下檢視埠是否被佔用以及檢視所有埠Linux
- ubuntu 開啟/關閉ubuntu防火牆Ubuntu防火牆
- Ubuntu 埠檢視及關閉Ubuntu
- centos 6.x 7.x防火牆開啟埠範圍IP地址 配置CentOS防火牆
- win10系統下如何使用防火牆開放埠Win10防火牆
- 分享:有關Linux伺服器(在防火牆iptables)開放埠的操作總結Linux伺服器防火牆
- 防火牆怎麼開啟防火牆
- 雲伺服器埠和防火牆埠配置伺服器防火牆
- 在Linux中,如何檢視開放的埠?Linux
- 伺服器window如何設定防火牆開放埠伺服器防火牆
- Ubuntu系統中防火牆的使用和開放埠Ubuntu防火牆
- 檢視Linux埠是否被開放@[環境部署]Linux
- Linux開啟防火牆並設定策略指令碼Linux防火牆指令碼
- win10防火牆關閉還是開啟好_win10防火牆關閉開啟有什麼影響Win10防火牆
- Linux 防火牆只允許指定IP 埠訪問Linux防火牆