[Linux]centos开放端口

版权声明:本文为博主原创文章,未经博主允许不得转载。有任何问题请邮件联系[email protected] https://blog.csdn.net/drdongshiye/article/details/81606242

前言

开放端口仅需要
执行以下命令:


iptables -L -n  查看防火墙端口开放情况
#编辑
vi /etc/sysconfig/iptables
#开放端口
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT

#重启防火墙
systemctl restart iptables.service

在配置过程中遇到的问题!!!!!!(新的机器很少能一次性配置成功的)
问题一CentOS下/etc/sysconfig/下找不到iptables文件

1. 随便写一条iptables命令配置个防火墙规则。如:iptables -P OUTPUT ACCEPT。
[root@iZ23gx7o02aZ /]# cd /etc/sysconfig/
[root@iZ23gx7o02aZ sysconfig]# iptables -P OUTPUT ACCEPT
2. service iptables save进行保存。
[root@iZ23gx7o02aZ sysconfig]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

问题二The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

1.先执行如下命令:
   systemctl stop firewalld
   systemctl mask firewalld
2.安装iptables services
    yum install iptables-services
3.设置开机启动
    systemctl enable iptables
4.重启iptables service
    systemctl restart iptables
5.执行保存配置命令
    service iptables save

**问题三**Redirecting to /bin/systemctl restart iptable.service
Failed to issue method call: Unit iptable.service failed to load: No such file or directory.**

据说从某个版本的Linux系统(CenterOS/RedHat)后就将service命令改了,如下
#systemctl restart iptables.service

猜你喜欢

转载自blog.csdn.net/drdongshiye/article/details/81606242
0条评论
添加一条新回复