参考資料 として network の 設定 方法の 例を 示す これは 実証は してい ない (計算機が 足りないので 行えない )
192.168.1.0 network -----------------------------------------pc7( other ) | | | gw pc10;IP: 192.168.1.1 | | | pc1 eth1 IP:192.168.1.2 pc1 eth0 IP:192.168.2.2 | | | | 192.168.2.0 network ------------------ | | pc2 eth0 IP:192.168.2.1 pc1 hostname :nyan domain :cat.kingd.om eth0 :192.168.1.2 eth1 :192.168.2.2 netmask :255.255.255.0
network interface eth0 eth1
# which ifconfig /sbin/ifconfig # /sbin/ifconfig eth0 192.168.2.2 broadcast 192.168.2.255 netmask 255.255.255.0 # /sbin/ifconfig eth1 192.168.1.2 broadcast 192.168.1.255 netmask 255.255.255.0
routing table
# which route /sbin/route # /sbin/route add -net 192.168.2.0 netmask 255.255.255.0 dev eth0 # /sbin/route add -net 192.168.1.0 netmask 255.255.255.0 dev eth1
check network interface eth0 eth1
# ifconfig eth0 Link encap:Ethernet HWaddr 00:D0:B7:29:65:7F inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 eth1 Link encap:Ethernet HWaddr 00:90:FE:23:46:32 inet addr:192.168.2.2 Bcast:192.168.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
check routing table
$ which netstat /bin/netstat $ /bin/netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
default gw の 設定は 後で 再度 行う ことにしておきます また IP forwarding を 有効に するためには
echo 1 > /proc/sys/net/ipv4/ip_forward
の 作業も 必要に なるでしょう、 取り敢えず 次の pc2 に ついて 設定 し ましょう。
network interface eth0
# /sbin/ifconfig eth0 192.168.2.1 broadcast 192.168.2.255 netmask 255.255.255.0
routing table
# /sbin/route add -net 192.168.2.0 netmask 255.255.255.0 dev eth0 # /sbin/route add default gw 192.168.2.2
check routing table
$ netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 192.168.2.2 0.0.0.0 UG 0 0 0 eth0
pc2 に 関係する事は これで 終わりです。さて 次は pc7 に ついて 考えると
pc7 (others) に 関しては 今 存在する 192.168.1.0 の ネットワーク に 関する物と 192.168.2.0 の ネットワーク に 接続 するためには pc1 の eth1 IP Adr 192.168.1.2 を gateway に 設定を して 192.168.1.0 の ネットワー ク と 192.168.2.0 の ネットワーク 以外の ネットワーク に 接続 するために pc10 の 192.168.1.1 を default gw に 設定します。
network interface eth0
# /sbin/ifconfig eth0 192.168.1.7x broadcast 192.168.1.255 netmask 255.255.255.0
IP Adr 192.168.1.7x で 7x としたのは 他に ある場合 各々 異なると 言う 事の 為に 7x としています。当然 1 や 2 には なりません pc10 が 192.168.1.1 であると 想定してるので また 0 でも 255 でも ありません 2〜 244 の 数字です Class C と 想定 しているので routing table を 設定 しましょう
# /sbin/route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0 # /sbin/route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.2 # /sbin/route add default gw 192.168.1.1
上から 順番に ネットワーク 自分自身 192.168.1.0 用
次は ネットワーク 192.168.2.0 用の gw の 設定
最後に それ以外の ネッ
トワーク に 接続するための default gw の 設定 というように なります。
$ netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.2.0 192.168.1.2 255.255.255.0 UG 0 0 0 eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
gw の 設定を 残しておいたので 追加 します
# /sbin/route add -net 192.168.2.0 netmask 255.255.255.0 dev eth0
# /sbin/route add -net 192.168.1.0 netmask 255.255.255.0 dev eth1
# /sbin/route add default gw 192.168.1.1
routing table は この様に なるでしょう
$ netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 192.168.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1
これは 図上 です 計算機が 足りないので 実証は していないので こうなる と 考えています だれか 計算機を 下さい
にゃんたろう 拝!
2005年11月30日 (水) 21:48:29 JST 作成
✈