Netfwd is network traffic forwarder (relay). The program is written for OpenBSD but must work on any BSD operating systems. Netfwd acts as a bridge between local and remote source. The source can be one of the following: TCP, UDP, UNIX socket and TTY device. Netfwd works with both IPv4 and IPv6 address families.

Working with TTY device means that you can redirect serial port (i.e. COM port) data to any destination. For example, it's possible to create software serial port loopback or forward serial port data to network (aka serial to network convertor).

Using this tool you can even convert one protocol into another. For example, you accept incoming connection on TCP port and forward it into UNIX socket on your local computer.

$ netfwd tcp local_port unix stream /tmp/sock

Or the program listens on the IPv4 address and forwards connections to IPv6 address.

$ netfwd inet tcp local_port inet6 tcp remote_host remote_port

The program writes all the data received from the network to the serial port.

# netfwd tcp local_port tty /dev/cua00 115200,8,N,1,H

Also you can configure all software to use local addresses for different services such as SMTP, HTTP proxy, DNS, etc... and just change addresses in one place when you are roaming between networks.

# netfwd inet tcp 25 inet tcp 25
# netfwd inet udp 53 inet udp 53
$ netfwd inet tcp 8080 inet tcp 8080

Remote modem: BSD to BSD

Using netfwd one can easily use modem connected to another BSD computer. Here is how it can be accomplished.

Computer with modem

In this example i use Nokia 6230i phone for connecting to the Internet. I use DKU-2 cable to connect the phone to the computer's USB port. cuaU0 will be created as soon as i connect phone to the computer. Now, i use netfwd to accept incoming connections on port 5555 and redirect all traffic to serial port cuaU0.

# netfwd -d -v tcp 5555 tty /dev/cuaU0 115200,8,N,1,H

Another computer

On this computer i use ppp(8) to connect to the Internet. Pay attention to the device parameter in the following config file(some parameters are specific to my phone and mobile operator, MTS in this example).

 set device remote_computer:5555/tcp
           \"\" ATZ OK-ATZ-OK AT+CGDCONT=1,\\\"IP\\\",\\\"\\\" \
           OK \\dATD\\T TIMEOUT 40 CONNECT"
 set phone "*99#"
 set speed 115200
 set login
 set timeout 0
 set ifaddr
 add default HISADDR
 enable dns

Remote modem: Windows to BSD

There are a lot of people that use Windows as their desktops. They also can benefit from using netfwd. I leave the phone connected to the BSD computer. Netfwd is still running waiting for incoming connections.

On Windows side we don't have such flexibility as our ppp(8) has. But we can use additional software to accomplish our task. We can use one of the programs that creates virtual serial port from the list in Wikipedia (most of them are commercial programs) and use default ppp dialer.


  • netfwd-0.4.tar.gz - connect to another host's address if connection cannot be established. Some minor fixes (Last updated: 20 nov 2007)

Old versions:

Ukrainian OpenBSD User Group
Get Firefox

Copyright © 2006-2016, Alexey Vatchenko. All rights reserved.
Designed by Vladimir Mostovoy.