Hi,
I try since few days to run a FreeBSD 8.2 gateway server with IPFW/NATD.
The server has 5 NIC, one is the internet port (em0), and the other (em1,em0,bge0,bge1) are bridged on bridge0.
I read the handbook and everywhere I can on the net (I'm not a good English reader), but even if the gateway server could ping on the internet and on local network, the computers on the local network cannot ping the internet (they can ping the gateway server).
The gateway server do the NAT when packets go in him to passes to the internet (I looked ip packets on the bridge0 and em0 with tshark), and the same when the packets come back, but the firewall catch it. I don't understand.
Here is my script (sorry, I'm French, so the the comments are in French too
)
If someone has an idea where I'm wrong, thanks so much !
And sorry again about my English, I do my best !
I try since few days to run a FreeBSD 8.2 gateway server with IPFW/NATD.
The server has 5 NIC, one is the internet port (em0), and the other (em1,em0,bge0,bge1) are bridged on bridge0.
I read the handbook and everywhere I can on the net (I'm not a good English reader), but even if the gateway server could ping on the internet and on local network, the computers on the local network cannot ping the internet (they can ping the gateway server).
The gateway server do the NAT when packets go in him to passes to the internet (I looked ip packets on the bridge0 and em0 with tshark), and the same when the packets come back, but the firewall catch it. I don't understand.
Here is my script (sorry, I'm French, so the the comments are in French too

If someone has an idea where I'm wrong, thanks so much !
And sorry again about my English, I do my best !
Code:
#!/bin/sh
#########################################################################################################
# Initialisation des regles
#########################################################################################################
ipfw -q -f flush
#########################################################################################################
# Declaration des variables
#########################################################################################################
cmd="ipfw -q add"
ifPublic="em0"
ifPrivate="bridge0"
ifPrivateInBr1="em1"
ifPrivateInBr2="em2"
ifPrivateInBr3="bge0"
ifPrivateInBr4="bge1"
ipLocalNet="10.0.0.0/8"
tcpPortsOK="20,21,22,25,53,80,123,443"
udpPortsOK="53,123"
#########################################################################################################
# Aucune restriction sur lo et le local
#########################################################################################################
$cmd 00005 allow all from any to any via lo0
$cmd 00006 allow all from any to any via $ifPrivate
$cmd 00007 allow all from any to any via $ifPrivateInBr1
$cmd 00008 allow all from any to any via $ifPrivateInBr2
$cmd 00009 allow all from any to any via $ifPrivateInBr3
$cmd 00010 allow all from any to any via $ifPrivateInBr4
#########################################################################################################
# enleve le NAT des adresses pour l'entree si necessaire
#########################################################################################################
$cmd 00015 divert natd ip from any to any in via $ifPublic
#########################################################################################################
# Autorise les tous les paquets réponses (dyn rules) (WAN -> Serveur/LAN)
#########################################################################################################
$cmd 00020 check-state
#########################################################################################################
# Paquets refuses (incoherants, connectes mais qui ne sont pas passes dans check-state, NetBIOS, etc.)
#########################################################################################################
$cmd 00030 deny all from 192.168.0.0/16 to any in via $ifPublic
$cmd 00031 deny all from 172.16.0.0/12 to any in via $ifPublic
$cmd 00032 deny all from 10.0.0.0/8 to any in via $ifPublic
$cmd 00033 deny all from 127.0.0.0/8 to any in via $ifPublic
$cmd 00034 deny all from 0.0.0.0/8 to any in via $ifPublic
$cmd 00035 deny all from 169.254.0.0/16 to any in via $ifPublic
$cmd 00036 deny all from 192.0.2.0/24 to any in via $ifPublic
$cmd 00037 deny all from 204.152.64.0/23 to any in via $ifPublic
$cmd 00038 deny all from 224.0.0.0/3 to any in via $ifPublic
$cmd 00039 deny all from any to any 113 in via $ifPublic
$cmd 00040 deny all from any to any 137 in via $ifPublic
$cmd 00041 deny all from any to any 138 in via $ifPublic
$cmd 00042 deny all from any to any 139 in via $ifPublic
$cmd 00043 deny all from any to any 81 in via $ifPublic
$cmd 00044 deny all from any to any frag in via $ifPublic
$cmd 00045 deny all from any to any established in via $ifPublic
#########################################################################################################
# Autorisation de requetes Serveur -> WAN
#########################################################################################################
$cmd 00100 allow tcp from me to any $tcpPortsOK out via $ifPublic setup keep-state
$cmd 00105 allow udp from me to any $udpPortsOK out via $ifPublic keep-state
$cmd 00110 allow icmp from me to any out via $ifPublic keep-state
$cmd 00199 deny log all from me to any out via $ifPublic
#########################################################################################################
# Autorisation de requetes WAN -> Serveur
#########################################################################################################
$cmd 00205 allow tcp from any to me 22 in via $ifPublic setup limit src-addr 2
$cmd 00210 allow tcp from any to me 80 in via $ifPublic setup limit src-addr 2
$cmd 00215 allow icmp from any to me in via $ifPublic limit src-addr 2
$cmd 00220 deny all from any to me in via $ifPublic
#########################################################################################################
# Autorisation LAN -> WAN
#########################################################################################################
$cmd 00300 skipto 600 icmp from $ipLocalNet to any out via $ifPublic keep-state
$cmd 00305 skipto 600 udp from $ipLocalNet to any out via $ifPublic keep-state
$cmd 00310 skipto 600 tcp from $ipLocalNet to any out via $ifPublic setup keep-state
#########################################################################################################
# Tout le reste est interdit
#########################################################################################################
$cmd 00500 deny log all from any to any
#########################################################################################################
# NATage pour la sortie si appelle (par le skipto)
#########################################################################################################
$cmd 00600 divert natd ip from any to any out via $ifPublic
$cmd 00605 allow ip from any to any out via $ifPublic