IPv6を使う他の方法(Debian+gogoNET その5)・・・Debianのip6tables

無事にDebianでFreenet6を使った固定IPv6接続ができるようになりましたが、いろいろ調べている間にIPv4とIPv6ではiptableが無関係っぽいことを目にしたので調べてみました。すると、Debianでは、

# ip6tables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

となっていて、確かに無防備です。一方で、IPv4は、

# iptables -L
Chain INPUT (policy DROP)
target prot opt source destination
ACCEPT (中略)

Chain FORWARD (policy DROP)
target prot opt source destination

Chain OUTPUT (policy DROP)
target prot opt source destination
ACCEPT (中略)

となっていて、それなり(設定したとおり)にブロックされています。

Ubuntuの方は、

~$ sudo ip6tables -L
Chain INPUT (policy DROP)
target prot opt source destination
ufw6-before-logging-input all anywhere anywhere
ufw6-before-input all anywhere anywhere
ufw6-after-input all anywhere anywhere
ufw6-after-logging-input all anywhere anywhere
ufw6-reject-input all anywhere anywhere
ufw6-track-input all anywhere anywhere

Chain FORWARD (policy DROP)
target prot opt source destination
ufw6-before-logging-forward all anywhere anywhere
ufw6-before-forward all anywhere anywhere
ufw6-after-forward all anywhere anywhere
ufw6-after-logging-forward all anywhere anywhere
ufw6-reject-forward all anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ufw6-before-logging-output all anywhere anywhere
ufw6-before-output all anywhere anywhere
ufw6-after-output all anywhere anywhere
ufw6-after-logging-output all anywhere anywhere
ufw6-reject-output all anywhere anywhere
ufw6-track-output all anywhere anywhere

   :
(長いので以下略)

となっていて、ちゃんと設定されていそうです。(中身解析してない・・・)
とりあえず、Ubuntu で ip6tables -S の出力内容を編集して、同じ内容を Debian で設定するシェルスクリプト作成することにしました。
・・・が、そのままではダメみたいで、いくつか修正しました。

まず、冒頭のINPUT,FORWARD,OUTPUTの設定の後の部分に、

ip6tables -F
ip6tables -Z
ip6tables -X

を足して、チェーンの内容、ユーザー定義チェーンの内容を初期化します。

さらに、http/httpsでのアクセスを試したいのと、sshでのアクセスをしたいので、途中のユーザー定義のINPUTチェーンの設定箇所に

ip6tables -A ufw6-before-input -p tcp –dport 80 -j ACCEPT
ip6tables -A ufw6-before-input -p tcp –dport 443 -j ACCEPT
ip6tables -A ufw6-before-input -p tcp –dport 22 -j ACCEPT

を追加したスクリプトを /usr/local/gogoc/bin の下に置くことにしました。後半の部分を削除したスクリプトではssh/httpでのアクセスができず、後半の部分ありのスクリプトを動かすと、httpでのアクセス、sshでのアクセスができることが確認できました。

これで、gogoc とそのスクリプトを起動すれば、IPv6でつかえていろいろできるはず・・・。です。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)