masquerade script

I had a script that I made to do masquerading in RH, now that I've switched to astaro I can't seem to get the masq. working properly. So I want to call back into sevice my old script, the problem is making it executable and running it on boot.

this is the script:
-----cut-----
#!/bin/sh
#
# Partial 2.4.x config to enable simple IP forwarding and Masquerading
# v0.61
#
#  NOTE:  The following is an example to allow only IP Masquerading for the 
#         192.168.0.2 and 192.168.0.8 machines with a 255.255.255.0 or a 
#         "/24" subnet mask connecting to the Internet on interface eth0.
#
#         ** Please change the network number, subnet mask, and the Internet
#         ** connection interface name to match your internal LAN setup
#
echo "  - Setting the default FORWARD policy to DROP"
$/usr/local/sbin/iptables -P FORWARD DROP

echo "  - Enabling SNAT (IPMASQ) functionality on $EXTIF"
$/usr/local/sbin/iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.0.23/32 -j MASQUERADE
$/usr/local/sbin/iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.0.3/32 -j MASQUERADE
$/usr/local/sbin/iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.0.4/32 -j MASQUERADE

echo "  - Setting the FORWARD policy to 'DROP' all incoming / unrelated traffic"
$/usr/local/sbin/iptables -A INPUT -i ppp0 -m state --state NEW,INVALID -j DROP
$/usr/local/sbin/iptables -A FORWARD -i ppp0 -m state --state NEW,INVALID -j DROP
-----cut-----

now, I've alrady done:chmod 755 rc.firewall
the problem is that when I try to run it I get this error:
bash: ./rc.firewall: No such file or directory

And in RH I just plopped this script into rc.local.. but astaro doesn't have an rc.local file, where should I put the call for this file?

help.  [:S]
Parents
  • Hi zenon,
    I can't see a reason why you wanted to stick with that script. Besides the point that your iptables rules will get removed if you change a filter setting in the WebAdmin (since it does not know about your Masquerading), it is nothing that can't be easily done with the WebAdmin.
    So why don't you just use the WebAdmin to integrate your 5 rules and do it "The Astaro Way" ?:-) 
    IMO this would be the better (and, overall, easier) solution.

    Greets,
    andreas
  • The problem is i tried to do it the astaro way and I couldn't get it to work...

    I found out the hard way that ALL rules are reset when you change one rule, my brother updated the firewall and suddenly NO MASQ!!!

    So please, a little help for a linux 'slightly-wet-behind-the-ears' and an astaro newbie... 

    Die M$, die!  
  • I notice now you say "5 rules" is the first rule "Setting the default FORWARD policy to DROP" not needed?

    thanx, for your help on my anti-M$ crusade.  [:)]
  • Hi zenon,
    ASL is a firewall, so there are already a few iptables filter rules in effect. To get an impression, you can do "iptables -L -nv" on the command line  [:)] 
    I don't know your Version, but I assume it is reasonably new. And if I got your Networking Setup right, you have a local network (internal, 192.168.0.0/24)  with a bunch of clients which should all be masqueraded to the one IP of your ppp interface. If I understood you right, you can replace that script with one Masquerading Rule. So, here are the details of working the magic:

    Go to Networking:NAT/Masquerading.
    To set up a masquerading rule, you must specify a network to masquerade and an interface to masquerade on. 
    Masquerading translates the source address of network packets, with 2 specialities: 
    - the source address is only translated if the packet leaves the firewall system via the specified interface 
    - the new source address is always the current IP of that interface (meaning that this address can be dynamic)

    So the only thing you have to set is a masquerading rule which specifies the internal network you want to masquerade and the external interface on which those packets will leave the firewall. That should do the trick.
    Remember to allow that traffic in the packet filter by applying a rule which allows traffic from the LAN to the internet.

    In short-short:      
    - go to Network->NAT/Masquerading and choose a name for your rule. You may call it "LAN_MASQ". 
    - Selecy "Masquerading" as the rule type. 
    - Select eth0_Network__ (or eth1,..., depends on your configuration) in the Network drop-down menu. 
    - Select your external interface (e.g. "ppp0") in the Interface drop-down menu 
    - Click the Add button to save and activate the rule
    - Apply a packet filter rule to allow internal to external traffic

    HTH,
    andreas
  • WOHOOO!!!

    It works now  [:)]ttle faster now)

    Thanks andreas!

    May my anti M$ crusade continue... Gentoo here i come.  [:)]
Reply Children
No Data