zoukankan      html  css  js  c++  java
  • 使用iptables基于MAC地址进行访控

    近日完成一台基于CentOS的SVN服务器配置,由于该服务器上的文件非常重要,仅部分用户需要访问,最后决定采用iptables来做访控,并且是根据MAC地址来限制,为了便于后期维护,防火墙的配置是通过一个bash脚本来完成的,该脚本内容如下:

    #!/bin/bash
    iptables=/sbin/iptables
    #Flush chains
    $iptables –F
    #Change the INPUT chains
    $iptables -A INPUT -m state --state INVALID -j DROP
    $iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
    #Read allowed mac from file /root/allow_mac
    for i in $(grep -v '^#' /root/allow_mac)
    do
        $iptables -A INPUT -m mac --mac-source $i -j ACCEPT
    done
    #Change the INPUT chain's default Policy to DROP
    $iptables -P INPUT DROP

       把允许访问的机器的MAC地址放入文件/root/allow_mac中,每个mac独占一行,然后编辑/etc/rc.local文件让系统在启动的时候执行该防火墙脚本即可。
    ---------------------
    作者:windowsxpwyd
    来源:CSDN
    原文:https://blog.csdn.net/windowsxpwyd/article/details/6253307
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    列表基本操作——1
    条件判断与嵌套
    数据拼接与数据转换
    变量与赋值
    打印数与type()函数
    print()函数与打印字符串
    arduino开发ESP8266学习笔记二----按键控制LED灯
    arduino开发ESP8266学习笔记一 ----点亮一个LED灯
    无线充电
    EMC设计总结
  • 原文地址:https://www.cnblogs.com/ricks/p/10259627.html
Copyright © 2011-2022 走看看