selektiv internetdeling
Er det muligt at tweake mit iptables script, til kun at dele internetforbindelsen med særlige maskiner på LAN (baseret på MAC adressen)Jeg har en liste af MAC jeg gerne vil dele internetforbindelsen med og udelukke resten.
Mit script ser idag således ud:
#!/bin/sh
# iptables script generator: V0.1-2002
# Comes with no warranty!
# e-mail: michael@1go.dk
# Diable forwarding
echo 0 > /proc/sys/net/ipv4/ip_forward
LAN_IP_NET='10.0.0.1/8'
LAN_NIC='eth0'
WAN_IP='12.14.19.14'
WAN_NIC='eth1'
# load some modules (if needed)
modprobe ip_nat_ftp
modprobe ip_conntrack_ftp
# Flush
iptables -t nat -F POSTROUTING
iptables -t nat -F PREROUTING
iptables -t nat -F OUTPUT
iptables -F
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
# enable Masquerade and forwarding
iptables -t nat -A POSTROUTING -s $LAN_IP_NET -j MASQUERADE
iptables -A FORWARD -i $LAN_NIC -j LOG
iptables -A FORWARD -j ACCEPT -i $LAN_NIC -s $LAN_IP_NET
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
# Open ports on router for server/services
iptables -A INPUT -j ACCEPT -p tcp --dport 80 #http
iptables -A INPUT -j ACCEPT -p tcp --dport 21 #ftp
iptables -A INPUT -j ACCEPT -p tcp --dport 22 #ssh
iptables -A INPUT -j ACCEPT -p tcp --dport 110 #pop3
iptables -A INPUT -j ACCEPT -p tcp --dport 25 #mail
iptables -A INPUT -j ACCEPT -p udp --dport 53 #NS
##dhcp server only open for LAN
iptables -A INPUT -j ACCEPT -p udp -i $LAN_NIC --dport 67
##snmp only for own host
iptables -A INPUT -j ACCEPT -p udp -s 127.0.0.1 --dport 161
# STATE RELATED for router
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Enable forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
