# NAT configuration



## ravis (May 24, 2011)

I am using FreeBSD 8.1, I am having difficulty getting NAT to work under the following scenario

```
[TV] <----ethernet--->[PC running FreeBSD8.1] <---- wireless --------------->[Router]---Internet
            10.0.0.100 -----------------10.0.0.102-------------------192.168.1.102---------------- 192.168.1.254
                (fixed IP) ----------------- (fixed IP)--------------------- (address allocated by Router DHCP)
```
The idea is for the TV to be able to send/receive trafffic from internet

  1. I can ping from PC to both TV and Router without any hastles. I can ping to "google.com" with no hastles.
  2. TV diagnostics tell me that it cant reach internet
  3. I checked to see if natd daemon is running and it was. 

Can some one let me know if I have missed something here. Any ideas on how I can debug this configuration?

Appreciate any suggestions.

My rc.conf, natd.conf and loader.conf file contents are as follows.

/etc/rc.conf

```
hald_enable="YES"
dbus_enable="YES"
moused_enable="YES"
wlans_ath0="wlan0"
ifconfig_wlan0="DHCP"
ifconfig_msk0="inet 10.0.0.254 netmask 255.255.255.0"
ifconfig_wlan0_alias0="inet 192.168.1.102 netmask 255.255.255.0"
#NAT Configuration follows
gateway_enable="YES"
natd_enable="YES"
#The interface that is connected to internet
natd_interface="wlan0"
#Here is where you keep all redirection info
natd_flags="-f /etc/natd.conf"
```

natd.conf

```
# We allow all ports to go in/out
redirect_port tcp 10.0.0.100:1-3000 1-3000
# We route all our TV stuff to Router(wireless)  192.168.1.254
#    or is to the LapTop ??? (192.168.1.102)   ... tried this aswell no luck
redirect_address 10.0.0.100 192.168.1.254
```

/boot/loader.conf

```
snd_ich_load="YES"  #Adding onboard Sound Controller Ravi
linux_load="YES"    #Linux Emulation
ipfw_load="YES"     #Enabling NAT
ipdivert_load="YES" #Enabling NAT
net.inet.ip.fw.default_to_accept="1"  #allow Any to Any
```


----------



## SirDice (May 24, 2011)

NAT is not needed as long as you fix the routing.


----------



## ravis (May 24, 2011)

Forgive my ignorance. My understanding is that for packets addressed to private network machines are not lost one should have NAT.

Anyway how should I setup the routing table. I have never done this before.


----------



## SirDice (May 24, 2011)

You'd only need NAT when you're going from a private range to the internet. Sending traffic back and forth between two private ranges can simply be done with routing.

Your FreeBSD machine has two addresses, one in 10.0.0.x/24 and one in 192.168.1.0/24. On your internet router add a static route for 10.0.0.0/24 and point it to the 192.168.1.x address of the FreeBSD machine. That should be all you need to do.


----------



## ravis (May 24, 2011)

Thanks for the explanation and quick response. I will give it a go.


----------



## ravis (May 26, 2011)

A simple static routing entry in the router, with PC configured as gateway did the trick. And I am thankful for your helpful suggestions, and the effort taken to tidy up my poor formatting of the posting. I am delighted to be part of such a well organized forum.


----------

