Linux开放8080端口

发布时间:2023-06-11 13:17        更新时间:2023-06-11 13:29

一.Centos7版本对防火墙进行 加强,不再使用原来的iptables,启用firewall

1.查看已开放的端口(默认不开放任何端口)

[root@localhost ~]# firewall-cmd –list-ports

2.开启8080端口

firewall-cmd –zone=public(作用域) –add-port=8080/tcp(端口和访问类型) –permanent(永久生效)

[root@localhost ~]# firewall-cmd –zone=public –add-port=80/tcp –permanent

3.重启防火墙

[root@localhost ~]# firewall-cmd –reload

4.停止防火墙

[root@localhost ~]# systemctl stop firewalld.service

5.禁止防火墙开机启动

[root@localhost ~]# systemctl disable firewalld.service

6.删除

[root@localhost ~]# firewall-cmd –zone= public –remove-port=80/tcp –permanent

 

二.Centos7以下版本(并未测试)

1.开放8080端口

[root@localhost ~]# /sbin/iptables -I INPUT -p tcp –dport 8080 -j ACCEPT

2.保存

[root@localhost ~]# /etc/rc.d/init.d/iptables save

3.查看打开的端口

[root@localhost ~]# /etc/init.d/iptables status

4.关闭防火墙

1) 永久性生效,重启后不会复原

开启: chkconfig iptables on

关闭: chkconfig iptables off

[root@localhost ~]# chkconfig iptables on

[root@localhost ~]# chkconfig iptables off

2) 即时生效,重启后复原

开启: service iptables start

关闭: service iptables stop

[root@localhost ~]# service iptables start

[root@localhost ~]# service iptables stop