Hey everyone,
I'm struggling I'm new to FreeBSD and trying to get up and running an IPFW firewall on my FreeBSD VPS.
I don't want to setup any NAT but only firewall filter rules.
My /etc/rc.conf
My /etc/ipfw.rules
When I ping any host in internet packets are transmitted but no packets return back applies for both ping6 and ping,
However, my SSH-TCP communication on the custom port works fine also when I ping direct host in internet like 8.8.8.8 it works fine and packets return as it should.
What lines am I missing to allow both directional TCP, ICMP and UDP traffic that's initiated by the machine?
Currently ICMP packets gets out but can't return back in.
I guess it's same for some UDP and TCP packets, but SSH works fine.
Thank you
sysmaq
I'm struggling I'm new to FreeBSD and trying to get up and running an IPFW firewall on my FreeBSD VPS.
I don't want to setup any NAT but only firewall filter rules.
My /etc/rc.conf
Code:
firewall_enable="YES"
firewall_quiet="YES"
firewall_type="open"
firewall_myservices="any"
firewall_allowservices="any"
firewall_logdeny="YES"
firewall_script="/etc/ipfw.rules"
Code:
#!/bin/sh
# Flush out the list before we begin.
ipfw -q -f flush
# Set rules command prefix
cmd="ipfw -q add"
pif="eth0" # interface name of NIC attached to Internet
# Change xl0 to LAN NIC interface name
# $cmd 00005 allow all from any to any via eth0
# No restrictions on Loopback Interface
$cmd 00010 allow all from any to any via lo0
$cmd 00101 check-state
# Outbound rules below
$cmd 00110 allow tcp from any to any out via $pif setup keep-state
$cmd 00111 allow udp from any to any out via $pif keep-state
$cmd 00112 allow icmp from any to any out via $pif keep-state
# Inbound rules below
# Deny all inbound traffic from non-routable reserved address spaces
$cmd 00303 deny all from 127.0.0.0/8 to any in via $pif loopback
$cmd 00304 deny all from 0.0.0.0/8 to any in via $pif loopback
$cmd 00306 deny all from 192.0.2.0/24 to any in via $pif reserved for docs
# 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 all Netbios services.
$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 inbound SSH connections
$cmd 00410 allow tcp from any to me 61748 in via $pif setup limit src-addr 2
#Reject and log all other incoming connections
$cmd 00499 deny log all from any to any in via $pif
#Everything else is denied and logged
$cmd 00999 deny log all from any to any
When I ping any host in internet packets are transmitted but no packets return back applies for both ping6 and ping,
However, my SSH-TCP communication on the custom port works fine also when I ping direct host in internet like 8.8.8.8 it works fine and packets return as it should.
What lines am I missing to allow both directional TCP, ICMP and UDP traffic that's initiated by the machine?
Currently ICMP packets gets out but can't return back in.
I guess it's same for some UDP and TCP packets, but SSH works fine.
Thank you
sysmaq
Last edited by a moderator: