mirror of
https://github.com/gentoo-mirror/gentoo-zh.git
synced 2025-04-10 20:08:43 -04:00
39 lines
810 B
Plaintext
39 lines
810 B
Plaintext
#!/sbin/runscript
|
|
|
|
RULES_D="/etc/iptables_rules.bak"
|
|
RULES="/etc/iptables_rules"
|
|
|
|
for IP in $(ifconfig | sed -n '/Mask:255\.255\.255/p' | awk '{print $2}' | awk -F : '{print $2}' | sed 's/\./\\\./g')
|
|
do
|
|
IP_RULES=${IP_RULES}"-A icmp_packets -s ${IP} -p icmp -m icmp --icmp-type 8 -j ACCEPT\n"
|
|
done
|
|
|
|
|
|
depend() {
|
|
need iptables
|
|
}
|
|
|
|
checkconfig() {
|
|
if [ ! -f ${RULES_D} ] ; then
|
|
eerror "You must give your default firewall rules in /etc/iptables_rules.bak"
|
|
return 1
|
|
fi
|
|
|
|
}
|
|
|
|
start() {
|
|
checkconfig || return 1
|
|
|
|
ebegin "Add local IP to firewall"
|
|
sed "s/-A icmp_packets -s 127\.0\.0\.1 -p icmp -m icmp --icmp-type 8 -j ACCEPT/${IP_RULES}/" ${RULES_D} > ${RULES}
|
|
iptables-restore ${RULES}
|
|
|
|
eend $?
|
|
}
|
|
|
|
stop() {
|
|
ebegin "Remove local IP from firewall"
|
|
iptables-restore ${RULES_D}
|
|
eend $?
|
|
}
|