デフォルトルート

SheevaPlug

SheevaPlug に依存する話じゃないと思うのだが、、、

root@debian:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

#auto eth0
#iface eth0 inet dhcp
# /usr/share/doc/ifupdown/examples for more information.
auto eth0
iface eth0 inet static
        address 192.168.2.85
        network 192.168.2.0
        netmask 255.255.255.0
        broadcast  192.168.2.255
#       gateway 192.168.2.1
root@debian:~#
と gateway をコメントアウトしているのに、
root@debian:~# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.2.0     *               255.255.255.0   U         0 0          0 eth0
default         trust.yamasita. 0.0.0.0         UG        0 0          0 eth0
root@debian:~#
デフォルトルートが存在する。

eth0 を down / up すると、、、

root@debian:~# ifdown eth0
root@debian:~# ifup eth0
root@debian:~# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.2.0     *               255.255.255.0   U         0 0          0 eth0
root@debian:~#
デフォルトルートがなくなる。

ネットワークケーブルを抜いてリブートすると、、、

root@debian:~# netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.2.0     *               255.255.255.0   U         0 0          0 eth0
default         192.168.2.1     0.0.0.0         UG        0 0          0 eth0
root@debian:~#
192.168.2.1 の逆引きはできていないが、 デフォルトルートがある。
ということは、 RIP のようなネットワークから情報を得ているのではない。
どこかに設定がある。
root@debian:~# cd /etc/init.d/
root@debian:/etc/init.d# grep route *
root@debian:/etc/init.d# 
/etc/init.d/ には無い。
root@debian:/etc/init.d# cd ..
root@debian:/etc# grep route *
hosts:ff02::2 ip6-allrouters
protocols:ipv6-route 43 IPv6-Route      # Routing Header for IPv6
services:route          520/udp         router routed   # RIP
sysctl.conf:# Do not send ICMP redirects (we are not a router)
sysctl.conf:# Do not accept IP source route packets (we are not a router)
sysctl.conf:#net.ipv4.conf.all.accept_source_route = 0
sysctl.conf:#net.ipv6.conf.all.accept_source_route = 0
root@debian:/etc# grep route */*
dhcp3/dhclient.conf:option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
dhcp3/dhclient.conf:request subnet-mask, broadcast-address, time-offset, routers,
dhcp3/dhclient.conf:    rfc3442-classless-static-routes;
dhcp3/dhclient.conf:#  option routers 192.33.137.250;
dhcp3/dhclient.conf.dpkg-dist:option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
dhcp3/dhclient.conf.dpkg-dist:request subnet-mask, broadcast-address, time-offset, routers,
dhcp3/dhclient.conf.dpkg-dist:  rfc3442-classless-static-routes, ntp-servers;
dhcp3/dhclient.conf.dpkg-dist:#  option routers 192.33.137.250;
dhcp3/dhclient.conf.old:option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
dhcp3/dhclient.conf.old:request subnet-mask, broadcast-address, time-offset, routers,
dhcp3/dhclient.conf.old:        rfc3442-classless-static-routes;
dhcp3/dhclient.conf.old:#  option routers 192.33.137.250;
iproute2/rt_protos:13   dnrouted
ppp/ip-down:# routes, unset IP addresses etc. you should create script(s) there.
ppp/ip-up:# It uses run-parts to run scripts in /etc/ppp/ip-up.d, so to add routes,
root@debian:/etc# grep route */*/*
dhcp3/dhclient-enter-hooks.d/debug:             new_routers new_static_routes old_ip_address old_subnet_mask \
dhcp3/dhclient-enter-hooks.d/debug:             old_routers old_static_routes; do
dhcp3/dhclient-exit-hooks.d/debug:                      new_domain_name_servers new_routers new_static_routes \
dhcp3/dhclient-exit-hooks.d/debug:                      old_domain_search old_domain_name_servers old_routers \
dhcp3/dhclient-exit-hooks.d/debug:                      old_static_routes; do
dhcp3/dhclient-exit-hooks.d/rfc3442-classless-routes:        if [ x"$new_rfc3442_classless_static_routes" != x"" ]; then
dhcp3/dhclient-exit-hooks.d/rfc3442-classless-routes:                        rfc_routes=($new_rfc3442_classless_static_routes)
dhcp3/dhclient-exit-hooks.d/rfc3442-classless-routes:                        for(( i=0; i < ${#rfc_routes[@]}; )); do
dhcp3/dhclient-exit-hooks.d/rfc3442-classless-routes:                                net_length=${rfc_routes[$i]}
dhcp3/dhclient-exit-hooks.d/rfc3442-classless-routes:                                        net_address[$j]=${rfc_routes[$i]}
dhcp3/dhclient-exit-hooks.d/rfc3442-classless-routes:                                        gateway[$j]=${rfc_routes[$i]}
dhcp3/dhclient-exit-hooks.d/rfc3442-classless-routes:                                        /sbin/route add -host "${net_address[*]}" gw "${gateway[*]}"
dhcp3/dhclient-exit-hooks.d/rfc3442-classless-routes:                                        /sbin/route add -net "${net_address[*]}/$net_length" gw "${gateway[*]}"
ppp/peers/em:defaultroute
ppp/peers/provider:# Use this connection as the default route.
ppp/peers/provider:defaultroute
root@debian:/etc# grep route */*/*/*
grep: */*/*/*: No such file or directory
root@debian:/etc#
節穴?見当たらない。

いったいどこでデフォルトルートを設定している?

ブート中のメッセージを良く見てみると、、、

IP-Config: Complete:
     device=eth0, addr=192.168.2.85, mask=255.255.255.0, gw=192.168.2.1,
     host=DB88FXX81, domain=, nis-domain=(none),
     bootserver=192.168.2.39, rootserver=192.168.2.39, rootpath=
eth0: link up, 1000 Mb/s, full duplex, flow control disabled
gw=192.168.2.1 を設定している。U-Boot の環境変数?
リブートして見てみる
Marvell>> printenv
	:
	:
bootargs=rootfstype=jffs2 console=ttyS0,115200 mtdparts=orion_nand:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs) rw root=/dev/mtdblock1 rw ip=192.168.2.85:192.168.2.39:192.168.2.1:255.255.255.0:DB88FXX81:eth0:none
	:
	:

Environment size: 1474/131068 bytes
Marvell>>
この設定がそのまま生きているのか???


←(前のページ)
Web カメラ
当月のハックの記録
SheevaPlug/玄柴(KURO-SHEEVA)をハックしよう トップ
(次のページ)→
電源プラグ型Linuxサーバ SheevaPlug+ モニター販売

Copyright (C) 2003-2010 Yasunari Yamashita. All Rights Reserved.
yasunari @ yamasita.jp 山下康成@京都府向日市