Wadah Belajar Linux, Debian, Mikrotik, Networking, Routing, dan Ilmu Pendukungnya

< Browse > Home / Linux, Networking, script / Blog article: Restore Iptables Secara Otomatis saat Booting

| Mobile | RSS

Restore Iptables Secara Otomatis saat Booting

February 11th, 2009 | No Comments | Posted in Linux, Networking, script

Ada script untuk ini via file init.d, akan tetapi ada alternatif lain yg bisa digunakan yaitu  via script networking ifup.d dimana akan di eksekusi saat ada perubahan status network interfaces.
Buat file “iptables” di direktori /etc/network/if-pre-up.d

#!/bin/sh

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

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

if test `$STAT –format=”%a” $IPSTATE` -ne “600″; then
echo “Permissions for $IPSTATE must be 600 (rw——-)”
exit 0
fi

if test `$STAT –format=”%u” $IPSTATE` -ne “0″; then
echo “The superuser must have ownership for $IPSTATE (uid 0)”
exit 0
fi

$RESTORE < $IPSTATE

Kemudian pastikan script tersebut bisa di eksekusi

# chmod +x iptables
# chown root:root iptables

Script ini akan me-load seting dari $IPSTATE – defaultnya /etc/iptables.conf.
Menyimpan rule iptables :

# iptables-save > /etc/iptables.conf

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Blogosphere News
  • Live
  • MisterWong
  • MySpace
  • Ping.fm
  • Slashdot
  • StumbleUpon
  • Technorati
  • Print
  • email
Leave a Reply 3001 views, 1 so far today |

Related Posts

Leave a Reply



View My Stats