Hello,
I have followed the instructions in the handbook regarding NAT and IPFW but somewhere along the line I have made a mistake. Unfortunately I had it going but when I went to re-apply it upon a server rebuild NAT refuses to work.
I am using the following ruleset script for ipfw(8) on FreeBSD 10.2.
10.0.0.1 - represents the ADSL modem that I have connected to the server via bge0. All NAT is done through em0 which represents the network segment 192.168.0.*.
Thanking you in advance,
Jonathan
I have followed the instructions in the handbook regarding NAT and IPFW but somewhere along the line I have made a mistake. Unfortunately I had it going but when I went to re-apply it upon a server rebuild NAT refuses to work.
I am using the following ruleset script for ipfw(8) on FreeBSD 10.2.
Code:
#!/bin/sh
# Flush out the list before we begin.
ipfw -q -f flush
# Set rules command prefix
cmd="ipfw -q add"
pif="bge0"
skip="skipto 500"
ks="keep-state"
good_tcpo="22,25,37,53,80,443,110"
# Change xl0 to LAN NIC interface name
$cmd 00005 allow all from any to any via em0
# No restrictions on Loopback Interface
$cmd 00010 allow all from any to any via lo0
$cmd 00100 divert natd ip from any to any in via $pif # NAT any inbound packets
$cmd 00101 check-state
# Allow access to public DNS
# Replace x.x.x.x with the IP address of a public DNS server
# and repeat for each DNS server in /etc/resolv.conf
$cmd 00110 allow tcp from any to 122.150.6.70 53 out via $pif setup keep-state
$cmd 00111 allow udp from any to 122.150.6.70 53 out via $pif keep-state
$cmd 00112 allow tcp from any to 122.150.7.70 53 out via $pif setup keep-state
$cmd 00113 allow udp from any to 122.150.7.70 53 out via $pif keep-state
# Authorized outbound packets
$cmd 120 $skip udp from any to 10.0.0.1 53 out via $pif $ks
$cmd 121 $skip udp from any to 10.0.0.1 67 out via $pif $ks
$cmd 125 $skip tcp from any to any $good_tcpo out via $pif setup $ks
$cmd 130 $skip icmp from any to any out via $pif $ks
# Allow outbound HTTP and HTTPS connections
$cmd 00200 allow tcp from any to any 80 out via $pif setup keep-state
$cmd 00220 allow tcp from any to any 443 out via $pif setup keep-state
# Allow outbound email connections
$cmd 00230 allow tcp from any to any 25 out via $pif setup keep-state
$cmd 00231 allow tcp from any to any 110 out via $pif setup keep-state
# Allow outbound ping
$cmd 00250 allow icmp from any to any out via $pif keep-state
# Allow outbound NTP
$cmd 00260 allow tcp from any to any 37 out via $pif setup keep-state
# Allow outbound SSH
$cmd 00280 allow tcp from any to any 22 out via $pif setup keep-state
# deny and log all other outbound connections
$cmd 00299 deny log all from any to any out via $pif
$cmd 00300 deny all from 192.168.0.0/16 to any in via $pif
$cmd 00301 deny all from 172.16.0.0/12 to any in via $pif
$cmd 00302 deny all from 10.0.0.0/8 to any in via $pif
$cmd 00303 deny all from 127.0.0.0/8 to any in via $pif
$cmd 00304 deny all from 0.0.0.0/8 to any in via $pif
$cmd 00305 deny all from 169.254.0.0/16 to any in via $pif
$cmd 00306 deny all from 192.0.2.0/24 to any in via $pif
$cmd 00307 deny all from 204.152.64.0/23 to any in via $pif
$cmd 00308 deny all from 224.0.0.0/3 to any in via $pif
# Deny public pings
$cmd 00310 deny icmp from any to any in via $pif
# Deny ident
$cmd 00315 deny tcp from any to any 113 in via $pif
#deny netbios
$cmd 00320 deny tcp from any to any 137 in via $pif
$cmd 00321 deny tcp from any to any 138 in via $pif
$cmd 00322 deny tcp from any to any 139 in via $pif
$cmd 00323 deny tcp from any to any 81 in via $pif
# Deny fragments
$cmd 00330 deny all from any to any frag in via $pif
# Deny ACK packets that did not match the dynamic rule table
$cmd 00332 deny tcp from any to any established in via $pif
# Allow traffic from ISP's DHCP server.
# Replace x.x.x.x with the same IP address used in rule 00120.
$cmd 00360 allow udp from any to 10.0.0.1 67 in via $pif keep-state
# Allow HTTP connections to internal web server
$cmd 00400 allow tcp from any to me 80 in via $pif setup limit src-addr 2
# Allow inbound SSH connections
$cmd 00410 allow tcp from any to me 22 in via $pif setup limit src-addr 2
# Reject and log all other incoming connections
$cmd 499 deny log all from any to any
$cmd 500 divert natd ip from any to any out via $pif # skipto location for outbound stateful
$cmd 510 allow ip from any to any
10.0.0.1 - represents the ADSL modem that I have connected to the server via bge0. All NAT is done through em0 which represents the network segment 192.168.0.*.
Thanking you in advance,
Jonathan