124583SdarrenrThese are Instructions for Configuring A FreeBSD Box For NAT 224583SdarrenrAfter you have installed IpFilter. 324583Sdarrenr 424583SdarrenrYou will need to change three files: 524583Sdarrenr 624583Sdarrenr/etc/rc.local 732030Ssteve/etc/rc.conf 824583Sdarrenr/etc/natrules 924583Sdarrenr 1024583SdarrenrYou will have to: 1124583Sdarrenr 1224583Sdarrenr1) Load the kernel module 1324583Sdarrenr2) Make the ipnat rules 1424583Sdarrenr3) Load the ipnat rules 1524583Sdarrenr4) Enable routing between interfaces 1624583Sdarrenr5) Add static routes for the subnet ranges 1724583Sdarrenr6) Configure your network interfaces 1824583Sdarrenr7) reboot the computer for the changes to take effect. 1924583Sdarrenr 2024583SdarrenrThe FAQ was written by Chris Coleman <chris@@bbcc.ctc.edu> 2124583SdarrenrThis was tested using ipfilter 3.1.4 and FreeBSD 2.1.6-RELEASE 2224583Sdarrenr_________________________________________________________ 2324583Sdarrenr1) Loading the Kernel Module 2424583Sdarrenr 2524583SdarrenrIf you are using a Kernal Loadable Module you need to edit your 2624583Sdarrenr/etc/rc.local file and load the module at boot time. 2724583Sdarrenruse the line: 2824583Sdarrenr 2924583Sdarrenr modload /lkm/if_ipl.o 3024583Sdarrenr 3124583SdarrenrIf you are not loading a kernel module, skip this step. 3224583Sdarrenr_________________________________________________________ 3324583Sdarrenr2) Setting up the NAT Rules 3424583Sdarrenr 3524583SdarrenrMake a file called /etc/natrules 3624583Sdarrenrput in the rules that you need for your system. 3724583Sdarrenr 3824583SdarrenrIf you want to use the whole 10 Network. Try: 3924583Sdarrenr 4024583Sdarrenrmap fpx0 10.0.0.0/8 -> 208.8.0.1/32 portmap tcp/udp 10000:65000 4124583Sdarrenr 4224583Sdarrenr_________________________________________________________ 4324583SdarrenrHere is an explaination of each part of the command: 4424583Sdarrenr 4524583Sdarrenrmap starts the command. 4624583Sdarrenr 4724583Sdarrenrfpx0 is the interface with the real internet address. 4824583Sdarrenr 4924583Sdarrenr10.0.0.0 is the subnet you want to use. 5024583Sdarrenr 5124583Sdarrenr/8 is the subnet mask. ie 255.0.0.0 5224583Sdarrenr 5324583Sdarrenr208.8.0.1 is the real ip address that you use. 5424583Sdarrenr 5524583Sdarrenr/32 is the subnet mask 255.255.255.255, ie only use this ip address. 5624583Sdarrenr 5724583Sdarrenrportmap tcp/udp 10000:65000 5824583Sdarrenr tells it to use the ports to redirect the tcp/udp calls through 5924583Sdarrenr 6024583Sdarrenr 6124583SdarrenrThe one line should work for the whole network. 6224583Sdarrenr_________________________________________________________ 6324583Sdarrenr3) Loading the NAT Rules: 6424583Sdarrenr 6524583SdarrenrThe NAT Rules will need to be loaded every time the computer 6624583Sdarrenrreboots. 6724583Sdarrenr 6824583SdarrenrIn your /etc/rc.local put the line: 6924583Sdarrenr 7024583Sdarrenripnat -f /etc/natrules 7124583Sdarrenr 7224583SdarrenrTo check and see if it is loaded, as root type 7324583Sdarrenr ipnat -ls 7424583Sdarrenr_________________________________________________________ 7524583Sdarrenr4) Enable Routing between interfaces. 7624583Sdarrenr 7724583SdarrenrTell the kernel to route these addresses. 7824583Sdarrenr 7924583Sdarrenrin the rc.local file put the line: 8024583Sdarrenr 8124583Sdarrenrsysctl -w net.inet.ip.forwarding=1 8224583Sdarrenr 8324583Sdarrenr_________________________________________________________ 8424583Sdarrenr5) Static Routes to Subnet Ranges 8524583Sdarrenr 8624583SdarrenrNow you have to add a static routes for the subnet ranges. 8724583SdarrenrEdit your /etc/sysconfig to add them at bootup. 8824583Sdarrenr 8924583Sdarrenrstatic_routes="foo" 9024583Sdarrenrroute_foo="10.0.0.0 -netmask 0xf0000000 -interface 10.0.0.1" 9124583Sdarrenr 9224583Sdarrenr 9324583Sdarrenr_________________________________________________________ 9424583Sdarrenr6) Make sure that you have your interfaces configured. 9524583Sdarrenr 9624583SdarrenrI have two Intel Ether Express Pro B cards. 9724583SdarrenrOne is on 208.8.0.1 The other is on 10.0.0.1 9824583Sdarrenr 9924583SdarrenrYou need to configure these in the /etc/sysconfig 10024583Sdarrenr 10124583Sdarrenrnetwork_interfaces="fxp0 fxp1" 10224583Sdarrenrifconfig_fxp0="inet 208.8.0.1 netmask 255.255.255.0" 10324583Sdarrenrifconfig_fxp1="inet 10.0.0.1 netmask 255.0.0.0" 10424583Sdarrenr_________________________________________________________ 105