近日完成一台基于CentOS的SVN服务器配置,由于该服务器上的文件非常重要,仅部分用户需要访问,最后决定采用iptables来做访控,并且是根据MAC地址来限制,为了便于后期维护,防火墙的配置是通过一个bash脚本来完成的,该脚本内容如下:
把允许访问的机器的MAC地址放入文件/root/allow_mac中,每个mac独占一行,然后编辑/etc/rc.local文件让系统在启动的时候执行该防火墙脚本即可。
#!/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
使用iptables基于MAC地址进行访控
最新推荐文章于 2024-12-02 15:52:53 发布
本文介绍了一台基于CentOS的SVN服务器如何通过iptables进行访问控制,利用MAC地址限制特定设备访问,防火墙配置由bash脚本自动化实现。
731

被折叠的 条评论
为什么被折叠?



