投げ銭

★当サイトへの投げ銭(PayPal)★

LINK


(無償、寄付歓迎) logo
世界中で使われるISO標準オフィスソフト(MSオフィス互換)

★LibreOfficeの導入事例★
詳細について

人気の投稿(1ヶ月間)

Ad

Ad

投げ銭

★当サイトへの投げ銭(PayPal)★

2018年3月31日土曜日

【RasPBX raspbx-03-12-2017】ip6tablesで設定するルールをシステム起動時にも反映させる【Raspberry Pi 2】


raspbx-03-12-2017.img で導入したRasPBXで、
iptables/ip6tablesで設定したルールをシステム再起動後にも継続させるために、
iptables-persistent パッケージを導入しようとしたところ、エラーが発生した。

# apt-get install iptables-persistent
(省略)
Unpacking netfilter-persistent (1.0.3+deb8u1) ...
Selecting previously unselected package iptables-persistent.
Preparing to unpack .../iptables-persistent_1.0.3+deb8u1_all.deb ...
Unpacking iptables-persistent (1.0.3+deb8u1) ...
Processing triggers for systemd (215-17+deb8u6) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up netfilter-persistent (1.0.3+deb8u1) ...
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
A dependency job for netfilter-persistent.service failed. See 'journalctl -xn' for details.
invoke-rc.d: initscript netfilter-persistent, action "start" failed.
dpkg: error processing package netfilter-persistent (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of iptables-persistent:
 iptables-persistent depends on netfilter-persistent (= 1.0.3+deb8u1); however:
  Package netfilter-persistent is not configured yet.
dpkg: error processing package iptables-persistent (--configure):
 dependency problems - leaving unconfigured
Processing triggers for systemd (215-17+deb8u6) ...
Errors were encountered while processing: netfilter-persistent iptables-persistentE: Sub-process /usr/bin/dpkg returned an error code (1)


■別の方法でシステム起動の際に自動的にIPフィルタルールを追加するようにした。

○適当な名前でルールを設定するスクリプトを作成した。
root@raspbx:~# nano /etc/ip6table.setting
/sbin/ip6tables -F
/sbin/ip6tables -P INPUT DROP
/sbin/ip6tables -P FORWARD DROP
/sbin/ip6tables -P OUTPUT ACCEPT
/sbin/ip6tables -A INPUT -i lo -j ACCEPT
/sbin/ip6tables -A INPUT -i eth0 -m state --state ESTABLISHED -j ACCEPT
/sbin/ip6tables -A INPUT -i eth0 -m state --state RELATED -j ACCEPT
/sbin/ip6tables -A INPUT -s fe80::/64 -p ipv6-icmp -m icmp6 --icmpv6-type 135 -j ACCEPT
/sbin/ip6tables -A INPUT -s fe80::/64 -p ipv6-icmp -m icmp6 --icmpv6-type 136 -j ACCEPT
/sbin/ip6tables -A INPUT -s fe80::/64 -j ACCEPT
○作成したスクリプトを実行できるようにした。
root@raspbx:~# chmod +x /etc/ip6table.setting

○問題なく実行できるか確認した。
root@raspbx:~# /etc/ip6table.setting

○起動時に実行されるrc.localファイルにスクリプトファイルのパスを追加した。
root@raspbx:~# nano /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Setting ip6tables rules
/etc/ip6table.setting 

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi
exit 0

以上

投げ銭

★当サイトへの投げ銭(PayPal)★

Ad

Ad