Guest User!

You are not Sophos Staff.

How to use DNAT/SNAT in a Astaro DHCP'd Boxen

Hey all,

I have created an easy hack to the "DHCP Client Hack" for cable modem users for Astaro that should also work for other hacks that do the same thing.

PROBLEM:

I had installed and configured the DHCP hack and was able to surf, and perform all the other functions that Astaro provides for. However, I could not get a DNAT/SNAT to work, because I had no way in the GUI to configure DNAT/SNAT to use the firewall external interface. Basically, the script when installed removed I think the "external" identifier that needs to be used to make DNAT/SNAT happen.

SOLUTION:

Here is the snipped section of the updateip file as shipped:


#Static entries:

echo "Hostname: your.domain.com" > /etc/wfe/conf/netzkartendata
echo eth0#Internal#10.10.10.10#255.255.255.0 >> /etc/wfe/conf/netzkartendata
echo X#InEmail#10.10.10.11#255.255.255.255#V > /etc/wfe/conf/netdata
echo X#InWeb#10.10.10.12#255.255.255.255#V >> /etc/wfe/conf/netdata
echo X#net_10#10.10.10.0#255.255.255.0#V >> /etc/wfe/conf/netdata

#Dynamic entries

#######################################
#Read from /etc/dhcpc/dhcpcd-eth1.info#
#######################################

ip="`cat /etc/dhcpc/dhcpcd-eth1.info | grep -i 'ipaddr' | awk '{print $1}' | sed -e 's/.*=//'`"
mask="`cat /etc/dhcpc/dhcpcd-eth1.info | grep -i 'netmask' | awk '{print $1}' | sed -e 's/.*=//'`"
echo eth1#External#$ip#$mask >> /etc/wfe/conf/netzkartendata

gateway="`cat /etc/dhcpc/dhcpcd-eth1.info | grep -i 'gateway' | awk '{print $1}' | sed -e 's/.*=//'`"
echo "Gateway: $gateway" >>/etc/wfe/conf/netzkartendata

echo X#OutEmail#$ip#255.255.255.255#V >> /etc/wfe/conf/netdata
echo X#OutWeb#$ip#255.255.255.255#V >> /etc/wfe/conf/netdata

I did not need to map a InWeb, InEmail, and net_10 entry, because the following modification fixes this so that in the GUI you may make any of these modifications and more for your DNAT/SNAT needs on a DCHO connection.

My snippet with the updated script entry.

echo "Hostname: myhost.mynetwork.com" > /etc/wfe/conf/netzkartendata
echo eth0#Internal#192.168.0.1#255.255.255.0 >> /etc/wfe/conf/netzkartendata
#Dynamic entries

#######################################
#Read from /etc/dhcpc/dhcpcd-eth1.info#
#######################################

ip="`cat /etc/dhcpc/dhcpcd-eth1.info | grep -i 'ipaddr' | awk '{print $1}' | sed -e 's/.*=//'`"
mask="`cat /etc/dhcpc/dhcpcd-eth1.info | grep -i 'netmask' | awk '{print $1}' | sed -e 's/.*=//'`"
echo eth1#External#$ip#$mask >> /etc/wfe/conf/netzkartendata

gateway="`cat /etc/dhcpc/dhcpcd-eth1.info | grep -i 'gateway' | awk '{print $1}' | sed -e 's/.*=//'`"
echo "Gateway: $gateway" >>/etc/wfe/conf/netzkartendata
echo X#External#$ip#255.255.255.255#V >> /etc/wfe/conf/netdata

Notice the line 

echo X#External#$ip#255.255.255.255#V

Underneath the Dynamic entries. This addition then allows you in the DNAT/SNAT configuration to specify as your outside or external correctly the "external" interface so that DNAT/SNAT will then work correctly.

You may also want to read my other post regarding fixing the netdata file so that when your IP changes, the DNAT/SNAT will be adjusted accordingly.

Thanks again to Astaro for a great product, and to the script writers responsible for creating and extending usefullness to the product.