#!/bin/bashadmin1=192.168.0.212 #Адмін 1admin2=192.168.0.11 #Адмін 2iface_external=eth0 #External interface - 217.25.199.160iface_internal=eth2 #Internal interface - 192.168.0.213ip_internal=192.168.0.213ip_external=217.25.199.160local_net=192.168.0.0/24#Portsftp_port=21ssh_port=22smtp_port=25http_port=80pop3_port=110https_port=443proxy_port=3128#Enable packet forward between interfacesecho "1" > /proc/sys/net/ipv4/ip_forward#Clear firewall rulesiptables --flushiptables -t filter -Fiptables -t filter -Xiptables -t nat -Fiptables -t nat -X#Default - all dropiptables -t filter -P INPUT DROPiptables -t filter -P FORWARD DROPiptables -t filter -P OUTPUT DROP#Enable pingiptables -t filter -A INPUT -p icmp -j ACCEPTiptables -t filter -A FORWARD -p icmp -j ACCEPTiptables -t filter -A OUTPUT -p icmp -j ACCEPT#Enable all on local interfaceiptables -t filter -A INPUT -d 127.0.0.1 -j ACCEPTiptables -t filter -A OUTPUT -s 127.0.0.1 -j ACCEPT# DNS.iptables -t filter -A INPUT -p tcp --sport 53 -j ACCEPTiptables -t filter -A FORWARD -p tcp --sport 53 -j ACCEPTiptables -t filter -A FORWARD -p tcp --dport 53 -j ACCEPTiptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPTiptables -t filter -A INPUT -p udp --sport 53 -j ACCEPTiptables -t filter -A FORWARD -p udp --sport 53 -j ACCEPTiptables -t filter -A FORWARD -p udp --dport 53 -j ACCEPTiptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT# Дозволити серверу виходити в інетiptables -t filter -A INPUT -i $iface_external -j ACCEPTiptables -t filter -A OUTPUT -o $iface_external -j ACCEPT#FTP# 21iptables -t filter -A INPUT -p tcp -s $admin1 -d $ip_internal --dport $ftp_port -j ACCEPTiptables -t filter -A INPUT -p tcp -d $admin1 -s $ip_internal --sport $ftp_port -j ACCEPTiptables -t filter -A INPUT -p tcp -s $admin2 -d $ip_internal --dport $ftp_port -j ACCEPTiptables -t filter -A INPUT -p tcp -d $admin2 -s $ip_internal --sport $ftp_port -j ACCEPT# SSHiptables -t filter -A INPUT -p tcp -s $admin1 -d $ip_internal --dport $ssh_port -j ACCEPTiptables -t filter -A OUTPUT -p tcp -d $admin1 -s $ip_internal --sport $ssh_port -j ACCEPTiptables -t filter -A INPUT -p tcp -s $admin2 -d $ip_internal --dport $ssh_port -j ACCEPTiptables -t filter -A OUTPUT -p tcp -d $admin2 -s $ip_internal --sport $ssh_port -j ACCEPT#SQUID (proxy)iptables -t filter -A INPUT -p tcp --dport $proxy_port -j ACCEPTiptables -t filter -A OUTPUT -p tcp --dport $proxy_port -j ACCEPTiptables -t filter -A FORWARD -p tcp --dport $proxy_port -j ACCEPTiptables -t nat -A POSTROUTING -d 0.0.0.0/0 -j MASQUERADE
iptables -t filter -A OUTPUT -p tcp --dport $proxy_port -j ACCEPT
iptables -t filter -A OUTPUT -p tcp --sport $proxy_port -j ACCEPT
PORT STATE SERVICE22/tcp open ssh111/tcp open rpcbind443/tcp open https885/tcp open unknown3128/tcp open squid-http3306/tcp open mysql5802/tcp open vnc-http-25902/tcp open vnc-26000/tcp filtered X116001/tcp filtered X11:16002/tcp filtered X11:26003/tcp filtered X11:36004/tcp filtered X11:46005/tcp filtered X11:56006/tcp filtered X11:66007/tcp filtered X11:76008/tcp filtered X11:86009/tcp filtered X11:96017/tcp filtered xmail-ctrl6050/tcp filtered arcserve10000/tcp open snet-sensor-mgmtMAC Address: 00:15:60:0E:B4:A2 (Unknown)Nmap run completed -- 1 IP address (1 host up) scanned in 1.812 seconds
PORT STATE SERVICE3128/tcp open squid-httpMAC Address: 00:14:38:B9:80:3E (Unknown)
# Generated by iptables-save v1.3.3 on Tue Mar 7 16:07:50 2006*filter:FORWARD DROP [0:0]:INPUT DROP [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -s 127.0.0.0/255.0.0.0 -i lo -j ACCEPT-A INPUT -s 192.168.0.1 -i lo -j ACCEPT-A INPUT -d 255.255.255.255 -j DROP-A INPUT -p tcp -m tcp -m state ! --tcp-flags SYN,RST,ACK SYN --state NEW -j DROP-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT-A INPUT -d 224.0.0.0/255.0.0.0 -j DROP-A INPUT -s 192.168.0.212 -p tcp -m tcp --dport 22 -j ACCEPT-A INPUT -s 192.168.0.11 -p tcp -m tcp --dport 22 -j ACCEPT-A INPUT -p icmp -m icmp -i eth0 --icmp-type any -j ACCEPT-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPTCOMMIT*mangle:FORWARD ACCEPT [0:0]:INPUT ACCEPT [0:0]:OUTPUT ACCEPT [0:0]:PREROUTING ACCEPT [0:0]:POSTROUTING ACCEPT [0:0]COMMIT*nat:OUTPUT ACCEPT [0:0]:PREROUTING ACCEPT [0:0]:POSTROUTING ACCEPT [0:0]COMMIT
iptables -t filter -A INPUT -i $iface_external -j ACCEPT
iptables -A INPUT -p ALL -i eth0 -s 0/0 -d 217.25.???.??? -m state --state ESTABLISHED,RELATED -j ACCEPT
# Rules for incoming packets from Internet$iptables -A INPUT -p ALL -m conntrack -i ${ExternalDevice} -s 0/0 -d ${ExternalHostIP} --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t filter -A FORWARD -p tcp --dport $proxy_port -j ACCEPT
Файервол паскудний... я би за такий погнав на перездачу
А нащо взагалі форвардінг хай всі через сквід ходять коли мможна...