zoukankan      html  css  js  c++  java
  • CentOS 7 下 安装Webmin 启动防火墙失败----Applying firewall rules:iptables-restore:line 2 failed

      最近学习CentOS 7 系统管理,使用的是《CentOS 6.X系统管理实战宝典》一书------因为网购的CentOS 7 的书还没有送到 O(‘  ’!!)O~

    (1)先使用yum方法安装Webmin:

      默认使用yum时无法安装Webmin,原因是该软件没有在官方站点存放。虽然以前要用tar方式安装,但是之后编译出了RPM安装包,所以只好自行配置更新站点。在/etc/yum.repo.d中创建webmin.repo文件,编辑完成后保存退出,然后导入Webmin开放源代码的GPG的数字签名:

    [root@localhost /]# vi /etc/yum.repos.d/webmin.repo
    [Webmin]
    name=Webmin Distribution Neutral
    baseurl=http://download.webmin.com/download/yum    //配置webmin安装来源站点
    enabled=1
    [root@localhost /]# rpm --import http://www.webmin.com/jcameron-key.asc

    然后使用yum方式进行安装,

    [root@localhost /]# yum install webmin

    (2)安装Apache软件:

    [root@localhost ~]# yum install httpd -y

    (3)想要安装Webmin系统管理工具,需要重新配置防火墙,Webmin默认使用的端口为10000,按照书上的教程设置了 /etc/sysconfig/iptables文件:

    [root@localhost /]# vi /etc/sysconfig/iptables
    #Firewall configuration written by system-config-firewall
    #Manual customization of this file is not recommanded.
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    -A INPUT -p icmp -j ACCEPT
    -A INPUT -i lo -j ACCEPT
    -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
    -A INPUT -m state --state NEW -m udp -p tcp --dport 10000 -j ACCEPT
    -A INPUT -j REJECT --reject-with icmp-host-prohibited
    -A FORWARD -j REJECT --reject-with icmp-host-prohibited
    COMMIT

    按照书上的教程执行 service iptables restart 命令,却失败了,以为是CentOS 6.X的命令和 CentOS 7 的命令不兼容的问题,网上搜CentOS 7启动防火墙的方法,找到这个网页:

    CentOS7下Firewall防火墙配置用法详解 

    按照如下图所示区域的Instruction,进行配置:

    ----------------------------------------以下为图片---------------------------------------------

    -----------------------------------------以上为图片----------------------------------------------

    (i) yum install iptables-services ,没有问题

    (ii) systemctl mask firewalld.service ,没有问题

    (iii) systemctl enable iptables.servie , 没问题

    为了提高网速,我禁用了ipv6,所以没有执行 systemctl start ip6tables.service

    (iv) systemctl stop firewalld.service , 没问题

    (v) systemctl start iptables.service ------ 有问题!

      如图:

    使用 cat /var/log/messages | grep iptables 命令查看相关错误:

    Applying firewall rules: iptables-restore:line 2 failed 得知是 iptables 文件的第二行由错,于是 cat /etc/sysconfig/iptables:

    一看,原来是 Manual configuration of this file is not recommended. 那句话没有在前面加上#号注释掉!

    遂注释之~

    再次 systemctl start iptables.service,结果:

    说是upd match: only valid for protocol 17

    最终从这个网页得到提示:http://stackoverflow.com/questions/25144598/failed-to-apply-firewall-rules-with-iptables-restore

    输入 iptables-restore < /etc/sysconfig/iptables:

    显示第14行有问题,但跟那个StackFlow网站的朋友的问题一样,我的第14行是 COMMIT:

    而他修改的方式是把 -p udp -m tcp 改为 -p udp -m udp, 而我检查我按照书上的Instruction写的iptables,也有这么一行 -m udp -p tcp ,应该是不匹配的问题。想到Webmin要用浏览器管理服务器,用的应该是tcp协议,于是将之改为 -m tcp -p tcp:

    再输入 systemctl start iptables.service, 没问题。

    输入 service httpd restart 命令重启 Apache 服务器, 浏览器登录Webmin管理器:

    可以看到登录界面了,说明iptables配置成功!

  • 相关阅读:
    IEnumerable、ICollection、IList、List关系和区别
    在Winform界面中使用DevExpress的TreeList实现节点过滤查询的两种方式
    关键字Lock的简单小例子
    .NET Core DI简单介绍
    Linux服务器部署.Net Core笔记:六、安装MySQL
    表的透视变换
    ZedGraph怎样在生成曲线时随机生成不一样的颜色
    3、手写Unity容器--第N层依赖注入
    微信支付-小程序H5 公众号 Payment SDK
    WPF继续响应被标记为已处理事件的方法
  • 原文地址:https://www.cnblogs.com/dongling/p/5601752.html
Copyright © 2011-2022 走看看