Download An Administrators Guide to Networking
Transcript
APPENDIX O. FIREWALL AND NAT addr=$2 else read -p "Type the mac address: " addr 94 95 96 fi 97 98 echo $addr >> /etc/allowed_macs 99 100 101 102 103 104 105 106 107 108 iptables -A FORWARD -i eth1 -m mac --mac-source $addr -s $lan -j ACCEPT ;; remove_mac) if [ $# = 2 ]; then addr=$2 else read -p "Type the mac address: " addr fi ←- 109 cat /etc/allowed_macs | grep -i -x -v $addr > /etc/ ←allowed_macs 110 111 iptables -D FORWARD -i eth1 -m mac --mac-source $addr -s $lan -j ACCEPT ;; 112 113 114 *) echo "Usage: /etc/init.d/ipt_setup (start|stop|restart ←|status|add_mac [MAC]|remove_mac [MAC])" exit 1 ;; 115 116 117 118 ←- esac 119 120 exit 0 Listing O.1: Script to Setup Firewall and NAT on Hubert The general script used to setup a basic firewall on the rest of the servers is listed in Listing O.2. 1 2 #! /bin/bash # /etc/init.d/ipt_setup 3 4 5 6 7 8 hubert=172.16.0.1 fry=172.16.0.2 hermes=172.16.0.3 zoidberg=172.16.0.4 bender=172.16.0.5 161