玄箱HGメモ/Debian/DHCPからIP取得
緑文字が入力コマンド。
Debian化キットでは固定IPアドレスだったのをDHCPから取得するように変更します。
管理者権限(管理者アカウント参照)で作業する必要があります。
ネットワークカードの設定を変更します。
KAGUYA:~# vi /etc/network/interfaces[ENTER]
/etc/network/interfacesの例
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or # /usr/share/doc/ifupdown/examples for more information.
以下の1行を追加
iface eth0 inet dhcp
以下の行は#で全てコメントアウト
旧
iface eth0 inet static # address 192.168.0.100 address 192.168.100.100 # network 192.168.0.0 network 192.168.100.0 # netmask 255.255.255.0 # broadcast 192.168.0.255 broadcast 192.168.100.255 # gateway 192.168.0.1 gateway 192.168.100.1
新
# iface eth0 inet static # address 192.168.0.100 # address 192.168.100.100 # network 192.168.0.0 # network 192.168.100.0 # netmask 255.255.255.0 # broadcast 192.168.0.255 # broadcast 192.168.100.255 # gateway 192.168.0.1 # gateway 192.168.100.1
iface lo inet loopback auto eth0 lo
上の方法で玉砕。
DPCPからIPアドレスは取得しているみたいですがSSHが拒否されて二度と繋がらなくなりました。
以下のように修正してチャレンジ。
いざと言う時用にエイリアスeth0:0で元のアドレスを残します。
KAGUYA:~# vi /etc/network/interfaces[ENTER]
/etc/network/interfacesの例
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or # /usr/share/doc/ifupdown/examples for more information.
以下の1行を追加
iface eth0 inet dhcp
以下の1行を#でコメントアウトして1行を追加
旧
iface eth0 inet static
新
# iface eth0 inet static iface eth0:0 inet static
# address 192.168.0.100 address 192.168.100.100 # network 192.168.0.0 network 192.168.100.0 netmask 255.255.255.0 # broadcast 192.168.0.255 broadcast 192.168.100.255 # gateway 192.168.0.1 gateway 192.168.100.1 iface lo inet loopback
以下の1行を#でコメントアウトして1行を追加
旧
auto eth0 lo
新
# auto eth0 lo auto eth0 eth0:0 lo
玄箱/HGをリブートします。
telnet/SSH接続します。
ホスト名がダメならIPアドレスで接続します。
IPアドレスはDHCPの管理画面で調べます。
DHCPの管理画面で調べたIPアドレスがダメなら/etc/hostsで指定したIPアドレスで接続します。
設定を表示して確認します。
管理者権限(管理者アカウント参照)で作業する必要があります。
KAGUYA:~# /sbin/ifconfig[ENTER]
ifconfig画面(例)
eth0 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX inet addr:192.168.100.220 Bcast:192.168.100.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:88 errors:0 dropped:0 overruns:0 frame:0 TX packets:71 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:6394 (6.2 KiB) TX bytes:5373 (5.2 KiB) Interrupt:16 Base address:0xf00 eth0:0 Link encap:Ethernet HWaddr XX:XX:XX:XX:XX:XX inet addr:192.168.100.100 Bcast:192.168.100.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:16 Base address:0xf00 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) KAGUYA:~#
XX:XX:XX:XX:XX:XXは玄箱/HGのMACアドレス。
echo0の
inet addr:192.168.100.220
はDHCPから取得しています。
etho0:0の
inet addr:192.168.100.100
は/etc/hostsと同じです。
作業終了です。
以降の作業を行わない場合は管理者アカウント終了してtelnet切断します。
コメントはありません。 コメント/玄箱HGメモ/Debian/DHCPからIP取得?
Online: 1