I have never used IPFW, and do not operate FreeBSD, so this example ruleset may not be correct. To craft these three lines, I spent two minutes with the
ipfw(8) man page and one additional minute with Chapter 30.4 of the FreeBSD Handbook.
As with any help you get from random people on the Internet, please use with caution.
Code:
ipfw add allow ipencap from any to any via <your internal NIC>
ipfw add allow udp from any 500 to any 500 via gif0
ipfw add allow esp from any to any via gif0