# Redirection with natd flags



## ahmednawar (Dec 24, 2013)

I am trying to set[ ]up a basic NAT server. I want all traffic coming from the outside world to the NAT server to be redirected to another machine, where I have a li*b*cap service running to parse this traffic.

I tried -redirect_port and -redirect_address in the natd_flags part in rc.conf but nothing works. Any thoughts?


----------



## fulano (Dec 24, 2013)

The correct syntax of /etc/natd.conf is:


```
redirect_port tcp ip:port port
```

Example:


```
redirect_port tcp 10.157.22.20:3310 3310
```

Without the leading dash ( - )

There is no need to use natd_flags.


----------



## ahmednawar (Dec 24, 2013)

Sso what about if I want to redirect all the traffic?


----------



## fulano (Dec 24, 2013)

There are many ways to redirect all traffic (NAT).

1. Using natd daemon:

In /etc/rc.conf:

```
gateway_enable="YES"
natd_enable="YES"
natd_interface="xx0" # The NIC connected do the internet
```

2. Using PF (the way I use)

In /etc/rc.conf:

```
gateway_enable="YES"
pf_enable="YES"
```

In /etc/pf.conf:

```
ext_if="xx0" # The NIC connected to the internet
lan={ 10.157.22.0/24 } # Your internal network
nat on $ext_if from  $lan to any -> ($ext_if)
```

Also it can be done with IPFW, check handbook.


----------

