Linux中如何開啟8080埠供外界訪問

2021-06-21 07:58:10 字數 2098 閱讀 1740

linux中如何開啟8080埠供外界訪問

1.修改檔案/etc/sysconfig/iptables

[root@bogon ~]#cd /etc/sysconfig/

[root@bogon sysconfig]#vi iptables

檔案內容如下,注意紅色一行是新加的,目的是對外界開放8080埠

# firewall configuration written by system-config-firewall

# manual customization of this file is not recommended.

*filter

:input accept [0:0]

:forward accept [0:0]

:output accept [0:0]

:rh-firewall-1-input - [0:0]

-a input -j rh-firewall-1-input

-a rh-firewall-1-input -i lo -j accept

-a rh-firewall-1-input -p icmp --icmp-type any -j accept

-a rh-firewall-1-input -p 50 -j accept

-a rh-firewall-1-input -p 51 -j accept

-a rh-firewall-1-input -p udp --dport 5353 -d 224.0.0.251 -j accept

-a rh-firewall-1-input -p udp -m udp --dport 631 -j accept

-a rh-firewall-1-input -p tcp -m tcp --dport 631 -j accept

-a rh-firewall-1-input -m state --state established,related -j accept

-a rh-firewall-1-input -m state --state new -m tcp -p tcp --dport 21 -j accept

-a rh-firewall-1-input -m state --state new -m tcp -p tcp --dport 22 -j accept

-a rh-firewall-1-input -m state --state new -m tcp -p tcp --dport 443 -j accept

-a rh-firewall-1-input -m state --state new -m tcp -p tcp --dport 80 -j accept

-a rh-firewall-1-input -m state --state new -m tcp -p tcp --dport 8080 -j accept

-a rh-firewall-1-input -j reject --reject-with icmp-host-prohibited

-a forward -j reject --reject-with icmp-host-prohibited

commit

這行文字實際是從上一行拷貝修改而來,在vi中拷貝一行用yy,拷貝多行用yyn,貼上用p。還算方便的。

2.將iptables服務重啟。

[root@bogon sysconfig]#service iptables restart

然後從外界訪問就可以了:

發布乙個war上去看看效果

3.如若不想修改iptables表,可以直接輸入下面命令:

#iptables -i input -p tcp --dport 80 -j accept

以上有問題請指出。

Linux中如何開啟8080埠供外界訪問

1.修改檔案 etc sysconfig iptables root bogon cd etc sysconfig root bogon sysconfig vi iptables 檔案內容如下,注意紅色一行是新加的,目的是對外界開放8080埠 firewall configuration writ...

linux中如何關閉 開啟SElinux

1 檢視核心 系統版本 root virtualboxcentos7 test hostnamectl static hostname virtualboxcentos7 icon name computer vm chassis vm machine id e8d08b54fc55254aaefd...

如何開啟PostGreSQL的遠端訪問埠?

用以下辦法即可 postgresql預設情況下,遠端訪問不能成功,如果需要允許遠端訪問,需要修改兩個配置檔案,說明如下 1.postgresql.conf 將該檔案中的listen addresses項值設定為 在9.0 windows版中,該項配置已經是 無需修改。2.pg hba.conf 在該...