このエントリーをはてなブックマークに追加


Ubuntu Serverインストール後にネットワークの設定を行った時の備忘録

Ubuntu14.04でも同様の操作で設定が可能でした。

Ubuntu16.04については、ネットワーク名称が変わったので別記事として書き直しました。

VirtualBoxを使用しゲストOSとしてUbuntu12.04 Serverをインストールした時のネットワーク設定の備忘録です。
VirtualBoxのネットワーク設定は以下の通りに設定し、ssh(teratermなど)による接続をホストOSからできるようにしました。

アダプター1NATDHCP
アダプター2ホストオンリーアダプタstatic

関連資料

ネットワーク設定を行うための設定ファイル

ネットワーク設定を行うために以下のファイルを編集しIPアドレスなどを設定します。

/etc/network/interfaces

編集するためのエディタを使用します。
nanoやviを使ってファイルを開きます。

  • nanoの場合
    sudo nano /etc/network/interfaces
  • viの場合
    sudo vi /etc/network/interfaces

本備忘録で/etc/network/interfacesの編集前・編集後

/etc/network/interfacesの内容を以下に記します。

設定は以下のようにしました。

eth0アダプター 1DHCP
eht1アダプター 2static 192.168.56.12/24

編集前の/etc/network/interfaces

以下は編集前の/etc/network/interfacesの内容です。

sakura@ubuntu:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp
sakura@ubuntu:~$

編集後の/etc/network/interfaces

以下は編集後の/etc/network/interfacesの内容です。

#Host Only network interfaceの行以下が新規に追加した行になります。

sakura@ubuntu:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Host Only network interface
auto eth1
iface eth1 inet static
address 192.168.56.12
netmask 255.255.255.0
sakura@ubuntu:~$

設定を反映するためにネットワークの再起動

変更した内容を反映させるため以下のコマンドでネットワークの再起動をすることができます。

sudo /etc/init.d/networking restart

上記のネットワーク再起動後のifconfigを確認してみると、設定が反映されていることが確認できます。

Ubuntu14.04では上記のrestartを動かしても何も変化がありませんでした。
しかし ifup eth1 を行ったらネットワークインタフェースは活性化しました。

以上、Ubuntu ServerをVirtualBoxにインストール後にネットワーク設定をした時の備忘録でした。
TeraTermなどからのssh接続に時間がかかるようであれば以下の記事を参考にしてみてください。



トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-10-08 (土) 13:53:10