#!/bin/bashecho "1" > /proc/sys/net/ipv4/ip_forwardarp -f /root/mac.txtmodprobe iptable_natmodprobe ip_conntrackmodprobe ip_conntrack_ftpmodprobe ip_nat_ftpiptables -F INPUTiptables -F FORWARDiptables -F POSTROUTING -t natiptables -p FORWARD DROP#客户机绑定mac地址才能上网,这样防止恶意增加IP在公司内部上网,引起不安全隐患cat /root/mac.txt | while read LINEdoipaddress=`echo $LINE | awk '{print $1}'`macaddress=`echo $LINE | awk '{print $2}'`iptables -A FORWARD -s $ipaddress -m mac --mac-source $macaddress -j ACCEPTdone#网关上有几块网卡,eth0接的是外网IP地址,eth1、eth2等对应该局域网IP,因是租用了电信的光纤,不存在着ADSL上网情况iptables -A FORWARD -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPTiptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j SNAT --to 59.195.233.234#iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j MASQUERADEcat /root/mac.txt192.168.1.50 00:16:D3:F6:BD:F5192.168.1.57 00:16:36:B4:6C:5D