IP Table Problem

There are 5 replies in this Thread which was already clicked 294 times. The last Post () by csr1.

  • Hi,
    i have made up a IP Table for Blocking some incoming IP's as one of my users was hacked however after entering some IP's after Reboot they are saved but when i enter a new IP it overwrites all of the old entries where am i going wrong?
    Here is my config:


    I used a script in the following location /etc/network/if-pre-up.d/iptables



    This script is:


    #!/bin/sh


    # Load iptables rules before interfaces are brought online
    # This ensures that we are always protected by the firewall
    #
    # Note: if bad rules are inadvertently (or purposely) saved it could block
    # access to the server except via the serial tty interface.
    #


    RESTORE=/sbin/iptables-restore
    STAT=/usr/bin/stat
    IPSTATE=/etc/iptables.conf


    test -x $RESTORE || exit 0
    test -x $STAT || exit 0


    # Check permissions and ownership (rw------- for root)
    if test `$STAT --format="%a" $IPSTATE` -ne "600"; then
    echo "Permissions for $IPSTATE must be 600 (rw-------)"
    exit 0
    fi


    # Since only the owner can read/write to the file, we can trust that it is
    # secure. We need not worry about group permissions since they should be
    # zeroed per our previous check; but we must make sure root owns it.
    if test `$STAT --format="%u" $IPSTATE` -ne "0"; then
    echo "The superuser must have ownership for $IPSTATE (uid 0)"
    exit 0
    fi


    # Now we are ready to restore the tables
    $RESTORE < $IPSTATE



    when i save an entry i do the following:


    iptables-save > /etc/iptables.up.rules


    as stated earlier after reboot old entries are in the iptables.up.rules


    but when a new entry is saved the old are wiped?




    Thanks
    csr1

  • Hi,
    thanks for response so instead of:


    RESTORE=/sbin/iptables-restore

    It should be RESTORE=/sbin/iptables-restore</var/etc/iptables.conf


    sorry for my query but not great with command lines.
    csr1


  • Hi,
    i tried to alter my script but have not succeeded in restoring IP table after reboot however if i manually enter iptables-restore </var/etc/iptables.conf the ip's i saved return.
    One other thing i tried was to take out my script and using scheduled tasks i put in / iptables-restore </var/etc/iptables.conf to kick in at reboot this did not work so still very confused how to automate restoring blocked ip's after reboot.
    thanks
    csr1

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!