Defcon1-Header
Tool-BarfreeBSD ArticlesSearch Our SiteHOMEfreeBSD LinksContribute to FreeBSD HelpFreeBSD FilesFreeBSD Script Corner

Yet Another NATD How-To

Ok after the past few days many people in #freebsdhelp have asked the channel howto do natd. Well first of all natd is a daemon to route data from one protocol to another. For instance if you have a cable modem and two nic's. ( Network Interface Card ). So one nic can have the cable modem and the other nic can have the lan. Then all the computers on the lan can access traffic on the cable modem through natd. If you are wanting to do this then you are going to need gateway_enable="YES" in your  /etc/rc.conf to. Remember you will need a firewall enabled. This is just a natd howto.

Ok now down to business.

1) Place these lines in your /etc/rc.conf and change ep0 to the nic/protocol that you use to access the internet. For example on my network, ep0 has the internet connection through the cable modem and rl0 has the lan connection. So if tun0 has the internet connection ( ppp ) then you would put tun0 instead of ep0.

natd_program="/sbin/natd"
natd_enable="YES"
natd_interface="ep0"
natd_flags="-config /etc/rc.natd -same_ports -log -use_sockets -dynamic"

2) Edit /etc/rc.natd ( this is where you place all your forwarding rules... you can
forward ports with natd so people out in the real world can access certain ports
on a lan box ).

This is what I have in my /etc/rc.natd

redirect_port tcp 10.0.0.1:51210 51210
redirect_port udp 10.0.0.1:51201 51201
redirect_port udp 10.0.0.1:51200 51200

You have the choice between tcp and udp and the port.
It is straight forward what to edit.
10.0.0.1 = The lan ip.
51210 = The port.

After editing /etc/rc.natd for changes to occur you must reboot.

3) shutdown -r now

  whisky

© 1997 - 20013 Defcon1, www.defcon1.org , Copyrights for all materials on this web site are held by the individual authors, artists, photographers or creators. Materials may not be reproduced or otherwise distributed without permission of www.defcon1.org and the content's original author.

Defcon1-Header2
Tool-Bar-2Defcon1  Webmail