CentOS6/CentOS7下开启端口

来源:互联网 发布:win10添加网络驱动器 编辑:程序博客网 时间:2024/05/18 01:06

--CentOS6

--开启端口
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables status
--重启防火墙
service iptables restart

--查看哪些端口已经开启服务
netstat -lutpn
--查看tomcat进程
ps -ef|grep tomcat
--杀进程
kill -9 ...
--查看某端口是否打开
netstat -an | grep 8080


--CentOS7

开启端口:
firewall-cmd --zone=public --add-port=80/tcp --permanent
命令含义:
--zone#作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议
--permanent#永久生效,没有此参数重启后失效
重启防火墙

firewall-cmd --reload 或者service firewalld restart


关闭防火墙

service firewalld stop




0 0