vagrant-lxc でIPアドレスを指定する

このエントリーをはてなブックマークに追加
はてなブックマーク - vagrant-lxc でIPアドレスを指定する
Facebook にシェア
[`yahoo` not found]
[`livedoor` not found]
[`friendfeed` not found]
[`tweetmeme` not found]

vagrant-lxcのboxでは「config.vm.network :private_network」の設定をサポートしていません。

たとえばVagrantfileで下記のように設定してupします。

config.vm.network :private_network, ip: "192.168.10.25"

下記のようにいわれてIPアドレスは設定できません。

$ vagrant up --provider=lxc
[default] Warning! The LXC provider doesn't support any of the Vagrant public / private
network configurations (ex: `config.vm.network :private_network, ip: "some-ip"`).
They will be silently ignored.

代わり「customize ‘network.ipv4’, ‘some-ip’」とします。

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

  config.vm.box = "lxc-precise-amd64"
  config.vm.box_url = "lxc-precise-amd64-2013-07-12.box"

  config.vm.provider :lxc do |lxc|
    lxc.customize 'network.ipv4', '10.0.3.102/32'
  end

end

指定したIPがつきます。

$ vagrant up --provider=lxc
$ vagrant ssh
$ /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:00:00:00:00:00  
          inet addr:10.0.3.102  Bcast:255.255.255.255  Mask:255.255.255.255
          inet6 addr: fexx::xxx:xxxx:xxxx:4070/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:95 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:13905 (13.9 KB)  TX bytes:10867 (10.8 KB)
$ exit

SSHでログインもok.

$ ssh vagrant@10.0.3.102
vagrant@10.0.3.102's password: 
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-56-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
Last login: Thu Dec  5 08:54:16 2013 from 10.0.3.1

Popular Posts:

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

*