Port forwarding on OpenBSD

I’ve never used OpenBSD, but I’ve heard that the BSD-flavours are great for routing (using a physical box).

Since the support subforum is purged after two weeks, I thought a nice “guide” to do port forwarding on a OpenBSD box was in place.

Disclaimer: I have no tried this but considering ‘Slycer’ did it (and assuming he/she didn’t leave anything out), I have no reason to doubt.

(The code is a copy-paste from Slycer’s configure file.)

# cat /etc/pf.conf
# $OpenBSD: pf.conf,v 1.31 2006/01/30 12:20:31 camield Exp $
# See pf.conf(5) and /usr/share/pf for syntax and examples.
# Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
# in /etc/sysctl.conf if packets are to be forwarded between interfaces.

# — MACRO section
# — Change ext_ip to your external IP (www.whatismyip.com eg)
ext_if = rl0
int_if = rl1
ext_ip = “”

# — Write here the internal IP the box you want to forward the port to
Dc = “”

# — Write here which ports you wish to forward
DcUDP = “1111”
DcTCP = “2222”

# — OPTIONS section
set skip on lo0
set skip on $int_if

nat pass on $ext_if inet from any -> $ext_if

rdr pass on $ext_if proto { tcp, udp } from any to any port { $DcTCP, $DcUDP } -> { $Dc }

# — FILTER section

# — default policy
block log all

pass out quick on $ext_if inet all keep state

You should then input your external IP in DC++ and then input the DcUDP/DcTCP ports in DC++.

One Response to Port forwarding on OpenBSD

  1. emtee says:

    If anyone interested for BSD based firewalling there’s a great tool M0nOwall which based on a bootable “live” FreeBSD image.
    Its a hell lot better than any cheap router we used it successfully as a solution for firewalling and routing small business and bigger networks. Its highly scalable and configurable through WEB based config utility and needs almost no hw resources.
    Its free ofcourse. http://m0n0.ch/wall/

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: