We have:
Gateway, two network cards (WAN and LAN)
script ipfw (rules NAT)
Task!
add a third network card (2nd provider)
Redirect the network computer 192.168.0.2 when accessing site.com to the second provider (using NAT 2)
Question
How to write redirect rules for nat2 ?
Gateway, two network cards (WAN and LAN)
script ipfw (rules NAT)
Code:
#rc.conf
gateway_enable="YES"
ifconfig_em0="inet XX.XX.XX.XX netmask 255.255.255.0" #provider
ifconfig_em1="inet 192.168.0.1 netmask 255.255.255.0" #local
defaultrouter="XX.XX.XX.XX"
Code:
#firewall (fragment)
/sbin/ipfw -q -f flush
fwcmd="/sbin/ipfw -q"
LIF="em1" #local
LIP="`ifconfig $LIF|awk '/inet /{print \$2}'`"
LAN="$LIP/24"
WIF="em0" #provider
WIP="`ifconfig $WIF|awk '/inet /{print \$2}'`"
WAN="$WIP/24"
${fwcmd} add 1100 allow ip from any to any via lo0
${fwcmd} add 3100 allow ip from any to $LAN in via $LIF
${fwcmd} add 3110 allow ip from $LAN to any out via $LIF
${fwcmd} add 3160 allow udp from any to $WIP 53 in via $WIF
${fwcmd} add 3170 allow udp from $WIP 53 to any out via $WIF
${fwcmd} add 3180 allow udp from any 53 to $WIP in via $WIF
${fwcmd} add 3190 allow udp from $WIP to any 53 out via $WIF
${fwcmd} nat 1 config log if $WIF same_ports
${fwcmd} add 10000 nat 1 all from any to any via $WIF
add a third network card (2nd provider)
Redirect the network computer 192.168.0.2 when accessing site.com to the second provider (using NAT 2)
Question
How to write redirect rules for nat2 ?