Ubuntu 資料一覧

IPエイリアスの設定

2012/11/3更新

対応バージョン: 11.10~12.10

/etc/network/interfacesに記述する。

例えばeth0に対して2つのIPエイリアスを設定する場合はそれぞれ「:0」「:1」付きの設定を加える。

例)

% sudo vi /etc/network/interfaces
:
auto eth0:0
iface eth0:0 inet static
address 192.168.0.110
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1

auto eth0:1
iface eth0:1 inet static
address 192.168.0.111
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1

設定後、以下のコマンドで設定を有効にする。

% sudo service networking restart
% ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 00:22:68:5c:42:28 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.11/24 brd 192.168.0.255 scope global eth0
    inet 192.168.0.110/24 brd 192.168.0.255 scope global secondary eth0:0
    inet 192.168.0.111/24 brd 192.168.0.255 scope global secondary eth0:1
    inet6 fe80::222:68ff:fe5c:4228/64 scope link 
       valid_lft forever preferred_lft forever

eth0:0とeth0:1が追加されているのが確認できる。

関連資料・記事