Linuxマシンを複数のクライアントからのパケットを処理するルータとして利用する場合、IPフォワード機能をオンにする必要がある。IPv4転送とも呼ばれるこの機能を有効にするには、次のような2つの方法がある。共に、/proc/sys/net/ipv4/ip_forwardファイルの内容を「1」=「有効」にするためのものだ。
1.linuxconfで設定する
linuxconfであればGUIで設定が可能だ。「Enable routing」をチェックすればよい
2.proc/に直接書き込む
echo 1>/proc/sys/net/ipv4/ip_forward
上記のコマンドを、rc.localなどの自動実行されるスクリプトファイルに書き込んでおくのが一般的だ
次に、一般的には/etc/sysconfig/networkファイルが参照されるが、Red Hat Linux 6.2では/etc/sysctl.confファイルの設定内容が起動時に参照される。Red Hat Linux 6.2ユーザーであれば、次のように/etc/sysctl.confを編集しよう。
NETWORKING=yes HOSTNAME=xxxxxxxx DOMAINNAME=xxxxxxxxxx GATEWAY=192.168.0.1 GATEWAYDEV=eth0 FORWARD_IPV4=yes ←フォワード設定 TIMESERVERATBOOT=no TIMESERVERTYPE=ntp TIMESERVERHOST=(none) TIMESERVERRESYNC=(none)
一般的には/etc/sysconfig/networkが参照される
# Disables IPv4 packet forwarding net.ipv4.ip_forward = 1 ←フォワード設定 # Enables source route verification # This drops packets that come in over interfaces they shouldn't; # (for example, a machine on an external net claiming to be one on your # local network) net.ipv4.conf.all.rp_filter = 1 # Disables automatic defragmentation # Automatic defragmentation is needed for masquerading and Linux # Virtual Server use; it is not needed otherwise. net.ipv4.ip_always_defrag = 0 # Disables the magic-sysrq key kernel.sysrq = 0 # Disables stop-a on the sparc kernel.stop-a = 0
Red Hat Linux6.2の場合は/etc/sysctl.confが参照される
Copyright © ITmedia, Inc. All Rights Reserved.