Total: - (Today: - Yesterday: - )
当然ながらポート開放作業は 自己責任でお願いします。
1.ルーターのポート開放
1.1.UPnPを使用する場合
- お使いのルーターの取扱説明書またはオンラインマニュアルを見ながら、UPnPを使用可能にします。
1.2.固定ポート30000/udpを使用する場合
- お使いのルーターの取扱説明書またはオンラインマニュアルを見ながら、ポート開放します。
- ポート開放がよくわからないという方は、こちらのサイト(ポート開放方法) を参照してもいいと思います。
- ポート開放の設定内容は次の通りです。
プロトコル udp
ポート 30000
使用ホストIPアドレス LinuxのIPアドレス
1.2.固定ポート34525/udpと34523/udpを使用する場合
- 30000/udpの方法でKai通信が安定しない場合、DeepPortとの併用で通信が安定するかもしれません。
- この場合、XLink Kai ConfigurationではPort=34525、DeepPort=34523を指定します。
プロトコル udp
ポート 34525
使用ホストIPアドレス LinuxのIPアドレス
プロトコル udp
ポート 34523
使用ホストIPアドレス LinuxのIPアドレス
2.Linuxのファイアウォール
- ディストリビューションによってファイアウォールの初期状態に違いがあります。ubuntu、debian、slackwareは初期状態ではフィルタが未定義で、すべての通信を許可してます。fedoraは初期状態ではフィルタが定義されてると思います。
- ファイアウォールを使用してない(通信をすべて許可している)場合、ここでは何も設定しません。次の実践編に進んでください。
- ファイアウォールを使用している場合、お使いのファイアウォールにKaiの通信を許可するルールを追加します。
2.1.UPnPを使用する場合
- 34522/tcpと1900/udpの通信を許可します。
2.2.固定ポートを使用する場合
- 34522/tcpと30000/udpの通信を許可します。
- または、34522/tcp、34525/udpと34523/udpの通信を許可します。
2.3. iptablesの設定例
- ここではiptablesによる設定例を載せてます。設定内容は間違っている箇所があるかもしれません、注意してください。あくまで家庭内LANのデスクトップ用途のLinux向けです。
- サンプルのため、UPnP、30000/udp、34525/udp、34523/udp、34522/tcpの全部を定義してます。実際には必要なものだけ定義します。また、XLink Kaiとは無関係の設定も含んでます。
$ touch iptables-up
$ chmod 700 iptables-up
$ vi iptables-up
#!/bin/sh
# Enter the NETWORK address the Internal Interface is on
INTNET='192.168.100.0/24'
# Enter the iptables command location
IPTABLES=/sbin/iptables # ubuntu, debian, fedora
#IPTABLES=/usr/sbin/iptables # slackware
# Any address
UNIVERSE='0.0.0.0/0'
# Clear any existing rules
$IPTABLES -F # Flush all chains
$IPTABLES -X # Delete all user specified chains
$IPTABLES -Z # Reset all counters
# Set default policies
$IPTABLES -P INPUT DROP
#$IPTABLES -P OUTPUT DROP
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD DROP
# Allow unlimited traffic on the loopback interface
$IPTABLES -A INPUT -i lo -j ACCEPT
$IPTABLES -A OUTPUT -o lo -j ACCEPT
# Previously initiated and accepted exchanges bypass rule checking
# Allow unlimited outbound traffic
$IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#$IPTABLES -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
# icmp
$IPTABLES -A INPUT -p icmp --icmp-type echo-request -s $INTNET -j ACCEPT
#$IPTABLES -A OUTPUT -p icmp --icmp-type echo-reply -d $INTNET -j ACCEPT
#$IPTABLES -A OUTPUT -p icmp --icmp-type echo-request -d $INTNET -j ACCEPT
$IPTABLES -A INPUT -p icmp --icmp-type echo-reply -s $INTNET -j ACCEPT
# UPnP 1900/udp
$IPTABLES -A INPUT -m state --state NEW -m udp -s $INTNET --sport 1900 -p udp -j ACCEPT
# XLinkKai 7.4.18/kaiWebUIPort 34522/tcp
$IPTABLES -A INPUT -m tcp -s $INTNET --dport 34522 -p tcp -j ACCEPT
# XLinkKai 7.4.18/kaiPort 30000/udp
#$IPTABLES -A INPUT -m udp -s $UNIVERSE --dport 30000 -p udp -j ACCEPT
# XLinkKai 7.0.0.7/kaiPort 34525/udp
$IPTABLES -A INPUT -m udp -s $UNIVERSE --dport 34525 -p udp -j ACCEPT
# XLinkKai 7.0.0.7/kaiDeepPort 34523/udp
$IPTABLES -A INPUT -m udp -s $UNIVERSE --dport 34523 -p udp -j ACCEPT}
# ssh 22/tcp
$IPTABLES -A INPUT -m state --state NEW,ESTABLISHED -m tcp -s $INTNET --dport 22 -p tcp -j ACCEPT
# ftp 21/tcp
$IPTABLES -A INPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -s $INTNET --dport 21 -p tcp -j ACCEPT
# samba 137/udp, 138/udp, 139/tcp, 445/tcp
$IPTABLES -A INPUT -m udp -s $INTNET --dport 137 -p udp -j ACCEPT
$IPTABLES -A INPUT -m udp -s $INTNET --dport 138 -p udp -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -m tcp -s $INTNET --dport 139 -p tcp -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -m tcp -s $INTNET --dport 445 -p tcp -j ACCEPT
# cups 631/tcp
$IPTABLES -A INPUT -m tcp -s $INTNET --dport 631 -p tcp -j ACCEPT
# statd, mountd, lockd 32765:32768/tcp, 32765:32768/udp
$IPTABLES -A INPUT -m tcp -s $INTNET --dport 32765:32768 -p tcp -j ACCEPT
$IPTABLES -A INPUT -m udp -s $INTNET --dport 32765:32768 -p udp -j ACCEPT
# nfs 2049/udp, 2049/tcp
$IPTABLES -A INPUT -m udp -s $INTNET --dport 2049 -p udp -j ACCEPT
$IPTABLES -A INPUT -m tcp -s $INTNET --dport 2049 -p tcp -j ACCEPT
# portmap 111/tcp, 111/udp
$IPTABLES -A INPUT -m tcp -s $INTNET --dport 111 -p tcp -j ACCEPT
$IPTABLES -A INPUT -m udp -s $INTNET --dport 111 -p udp -j ACCEPT
# Drop all other traffic
$IPTABLES -A INPUT -j DROP
$IPTABLES -A FORWARD -j DROP
$ touch iptables-down
$ chmod 700 iptables-down
$ vi iptables-down
#!/bin/sh
# Enter the iptables command location
IPTABLES=/sbin/iptables # ubuntu, debian, fedora
#IPTABLES=/usr/sbin/iptables # slackware
# Clear any existing rules
$IPTABLES -F # Flush all chains
$IPTABLES -X # Delete all user specified chains
$IPTABLES -Z # Reset all counters
# Set default policies
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
2.4.フィルタ定義のインストールとアンインストール
- すでに自前のフィルタ定義をお持ちの方は、以下の方法は実行しないでください。
- 定義ファイルから必要な箇所だけを抽出して、ご利用ください。
- ディストリビューション毎にインストール方法が違います。
2.4.1. ubuntu、debianの場合
$ touch iptables_install.sh
$ chmod 700 iptables_install.sh
$ vi iptables_install.sh
#!/bin/sh
test -f iptables-up || exit 1
cp iptables-up /etc/network/if-pre-up.d/iptables-up
chown root.root /etc/network/if-pre-up.d/iptables-up
test -f iptables-down || exit 1
cp iptables-down /etc/network/if-post-down.d/iptables-down
chown root.root /etc/network/if-post-down.d/iptables-down
$ sudo ./iptables_install.sh
- フィルタ規則定義ファイルをアンインストールするには??
$ touch iptables_uninstall.sh
$ chmod 700 iptables_uninstall.sh
$ vi iptables_uninstall.sh
#!/bin/sh
/etc/network/if-post-down.d/iptables-down
rm /etc/network/if-pre-up.d/iptables-up
rm /etc/network/if-post-down.d/iptables-down
$ sudo ./iptables_uninstall.sh
$ sudo iptables -L -v -n
2.4.2. fedoraの場合
$ touch iptables_install.sh
$ chmod 700 iptables_install.sh
$ vi iptables_install.sh
#!/bin/sh
test -f iptables-up || exit 1
/etc/rc.d/init.d/iptables stop
. ./iptables-up
/etc/rc.d/init.d/iptables save
/etc/rc.d/init.d/iptables start
/sbin/chkconfig iptables on
$ sudo ./iptables_install.sh
$ touch iptables_uninstall.sh
$ chmod 700 iptables_uninstall.sh
$ vi iptables_uninstall.sh
#!/bin/sh
test -f iptables-down || exit 1
/etc/rc.d/init.d/iptables stop
. ./iptables-down
/etc/rc.d/init.d/iptables save
/sbin/chkconfig iptables off
$ sudo ./iptables_uninstall.sh
2.4.3. slackwareの場合
$ touch iptables_install.sh
$ chmod 700 iptables_install.sh
$ vi iptables_install.sh
#!/bin/sh
test -f iptables-up || exit 1
. iptables-up
/usr/sbin/iptables-save > /etc/iptables.rules
$ sudo ~/iptables_install.sh
- OS起動時にフィルタを有効化するには/etc/rc.d/rc.localも修正します
$ sudo vi /etc/rc.d/rc.local
if [ -f /etc/iptables.rules ]; then
echo "Starting IPTABLES: /etc/iptables.rules"
/usr/sbin/iptables-restore < /etc/iptables.rules
fi
$ touch iptables_uninstall.sh
$ chmod 700 iptables_uninstall.sh
$ vi iptables_uninstall.sh
#!/bin/sh
test -f iptables-down || exit 1
. iptables-down
/usr/sbin/iptables-save > /etc/iptables.rules
$ sudo ~/iptables_uninstall.sh
2.5. iptablesの設定確認
- フィルタ定義を変更したら、iptablesの設定を確認しておきます。
- OS再起動したときにも定義が有効になっているかも確認しておいてください。
$ sudo iptables -L -v -n
Chain INPUT (policy DROP 12 packets, 1685 bytes)
pkts bytes target prot opt in out source destination
110 9052 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
24131 5251K ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
...
3 980 ACCEPT udp -- * * 192.168.100.0/24 0.0.0.0/0 state NEW udp spt:1900
6 288 ACCEPT tcp -- * * 192.168.100.0/24 0.0.0.0/0 tcp dpt:34522
62 12218 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:30000
...
2.6.ポートスキャンによるポート確認
- フィルタ定義が正しいか、ポートスキャンで確認します。
- Kaiを実行している状態でチェックします。
- 34522/tcpが開放されているか確認します。tcpプロトコルの場合、STATE=openの表示ならOKです。
$ sudo nmap -v -sT -p 34522 192.168.100.50
...
PORT STATE SERVICE
34522/tcp open unknown
...
- 30000/udpが開放されているか確認します。udpプロトコルの場合、STATE=open|filteredの表示ならOKです。
$ sudo nmap -v -sU -p 30000 192.168.100.50
...
PORT STATE SERVICE
30000/udp open|filtered unknown
...
2.7.ネットワーク状態の確認
- 30000/udpで接続している場合のネットワーク状態の例です。
- Kaiを実行している状態でチェックします。
$ netstat -lanput
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
...
tcp 0 0 192.168.100.50:34522 192.168.100.51:1737 ESTABLISHED -
tcp 0 0 192.168.100.50:34522 192.168.100.51:1735 ESTABLISHED -
tcp 0 0 192.168.100.50:34522 192.168.100.51:1738 ESTABLISHED -
tcp 0 0 192.168.100.50:38880 68.77.222.19:34525 (*1) ESTABLISHED -
tcp 0 0 192.168.100.50:34522 192.168.100.51:1733 ESTABLISHED -
tcp 0 0 192.168.100.50:34522 192.168.100.51:1734 ESTABLISHED -
tcp 0 0 192.168.100.50:34522 192.168.100.51:1736 ESTABLISHED -
udp 0 0 0.0.0.0:30000 0.0.0.0:* -
udp 0 0 0.0.0.0:34522 0.0.0.0:* -
...
(*1) 68.77.222.19 はKaiOrbitalServer(inxtec.net)のIPアドレスです。
以上で主なポート開放の設定は終わり。
コメント
最終更新:2010年08月10日 22:25