Страница 1 из 1

divert in firewall

Добавлено: 2006-11-23 13:55:33
maniac
Привет всем!!! Вот примерный конфиг фаера

Код: Выделить всё

#!/bin/sh -

setup_loopback () {
	############
	# Only in rare cases do you want to change these rules
	#
	${fwcmd} add 100 pass all from any to any via lo0
	${fwcmd} add 200 deny all from any to 127.0.0.0/8
	${fwcmd} add 300 deny ip from 127.0.0.0/8 to any
}


############
# Flush out the list before we begin.
#
${fwcmd} -f flush


	############
	# This is a prototype setup that will protect your system somewhat
	# against people from outside your own network.
	############

	# set these to your network and netmask and ip
	net="192.168.10.0"
	mask="255.255.255.0"
	ip="192.168.10.235"

	setup_loopback

	# Allow any traffic to or from my own net.
	${fwcmd} add pass all from ${ip} to ${net}:${mask}
	${fwcmd} add pass all from ${net}:${mask} to ${ip}

	# Allow TCP through if setup succeeded
	${fwcmd} add pass tcp from any to any established

	# Allow IP fragments to pass through
	${fwcmd} add pass all from any to any frag

	# Allow setup of incoming email
	${fwcmd} add pass tcp from any to ${ip} 25 setup

	# Allow setup of outgoing TCP connections only
	${fwcmd} add pass tcp from ${ip} to any setup

	# Disallow setup of all other TCP connections
	${fwcmd} add deny tcp from any to any setup

	# Allow DNS queries out in the world
	${fwcmd} add pass udp from ${ip} to any 53 keep-state

	# Allow NTP queries out in the world
	${fwcmd} add pass udp from ${ip} to any 123 keep-state

	############
	# This is a prototype setup for a simple firewall.  Configure this
	# machine as a DNS and NTP server, and point all the machines
	# on the inside at this machine for those services.
	############

	# set these to your outside interface network and netmask and ip
	oif="fxp0"
	onet="10.12.5.90"
	omask="255.255.255.240"
	oip="10.12.5.97"

	# set these to your inside interface network and netmask and ip
	iif="xl0"
	inet="192.168.1.0"
	imask="255.255.255.0"
	iip="192.168.10.235"

	setup_loopback

	# Stop spoofing
	${fwcmd} add deny all from ${inet}:${imask} to any in via ${oif}
	${fwcmd} add deny all from ${onet}:${omask} to any in via ${iif}

	# Stop RFC1918 nets on the outside interface
	${fwcmd} add deny all from any to 10.0.0.0/8 via ${oif}
	${fwcmd} add deny all from any to 172.16.0.0/12 via ${oif}
	${fwcmd} add deny all from any to 192.168.10.0/16 via ${oif}

	# Stop draft-manning-dsua-03.txt (1 May 2000) nets (includes RESERVED-1,
	# DHCP auto-configuration, NET-TEST, MULTICAST (class D), and class E)
	# on the outside interface
	${fwcmd} add deny all from any to 0.0.0.0/8 via ${oif}
	${fwcmd} add deny all from any to 169.254.0.0/16 via ${oif}
	${fwcmd} add deny all from any to 192.168.10.0/24 via ${oif}
	${fwcmd} add deny all from any to 224.0.0.0/4 via ${oif}
	${fwcmd} add deny all from any to 240.0.0.0/4 via ${oif}

	# Stop RFC1918 nets on the outside interface
	${fwcmd} add deny all from 10.0.0.0/8 to any via ${oif}
	${fwcmd} add deny all from 172.16.0.0/12 to any via ${oif}
	${fwcmd} add deny all from 192.168.10.0/16 to any via ${oif}

	# Stop draft-manning-dsua-03.txt (1 May 2000) nets (includes RESERVED-1,
	# DHCP auto-configuration, NET-TEST, MULTICAST (class D), and class E)
	# on the outside interface
	${fwcmd} add deny all from 0.0.0.0/8 to any via ${oif}
	${fwcmd} add deny all from 169.254.0.0/16 to any via ${oif}
	${fwcmd} add deny all from 192.168.10.0/24 to any via ${oif}
	${fwcmd} add deny all from 224.0.0.0/4 to any via ${oif}
	${fwcmd} add deny all from 240.0.0.0/4 to any via ${oif}

	# Allow TCP through if setup succeeded
	${fwcmd} add pass tcp from any to any established

	# Allow IP fragments to pass through
	${fwcmd} add pass all from any to any frag

	# Allow setup of incoming email
	${fwcmd} add pass tcp from any to ${oip} 25 setup

	# Allow access to our DNS
	${fwcmd} add pass tcp from any to ${oip} 53 setup
	${fwcmd} add pass udp from any to ${oip} 53
	${fwcmd} add pass udp from ${oip} 53 to any

	#Admin's access
	${fwcmd} add pass tcp from 192.168.10.17 to ${iip} 22
	${fwcmd} add pass all from ${iip} to 192.168.10.17
	
	# Allow access to our WWW
	${fwcmd} add pass tcp from any to ${oip} 80 setup

	# Reject&Log all setup of incoming connections from the outside
	${fwcmd} add deny log tcp from any to any in via ${oif} setup

	# Allow setup of any other TCP connection
	${fwcmd} add pass tcp from any to any setup

	# Allow DNS queries out in the world
	${fwcmd} add pass udp from ${oip} to any 53 keep-state

	# Allow NTP queries out in the world
	${fwcmd} add pass udp from ${oip} to any 123 keep-state
в rc.conf прописано следующее
firewall_enable="YES"
firewall_script="/usr/local/firewall"

natd_enable="YES"
natd_interface="fxp0"

когда ставлю тип фаервора открытый нат работает, через фаервол не хочет, куда я в конфиге фаера диверт не совал, помогите настроить работу фаера?

Добавлено: 2006-11-23 16:22:54
proxy-man
таак не годится... давай вывод:

Код: Выделить всё

#ipfw show
а уже вывод существующих в системе правил можно сравинть с конфиг.файлом для фаера..
А правила типа как у Лиса в статье -

Код: Выделить всё

# пропускаем траффик через трансляцию сетевых адресов (NAT)
${FwCMD} add divert natd ip from ${NetIn}/${NetMask} to any out via ${LanOut}
${FwCMD} add divert natd ip from any to ${IpOut} in via ${LanOut}
не канают?
При том прошу заметить шо нужно указывать именно тип IP для НАТа ибо когда я указывал ALL (все виды пакетов) - то у меня НАТ не отрабатывал...