Multiple IP address on same VM

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple IP address on same VM

Mathew Abraham
Hi guys,

I'm bit new to Vagrant and struggling to configure a VM with two network interface using host network configuration. Single static IP address is working fine. I'm using following code. 
I can see IP 192.168.11.69 defined in ifconfig but not 192.168.11.70 ??

OS image is RHEL 7.2


hosts = [
  { name: 'wcs_local_env',      hostname: 'wcs.testlab',  username: 'vagrant',  ip: ['192.168.11.69','192.168.11.70'], mbox: 'rhel64Node', },
]
Vagrant.configure("2") do |config|

  hosts.each do |host|
    config.vm.define host[:name] do |c|
         c.vm.box = host[:box]
         c.vm.hostname = host[:hostname]
    
          host[:ip].each_with_index do |ipadr, i|
          
            if i > 0
               c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0', :adapter => i
            else
               c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0'  
            end 
         
          end 

Thanks,
Mathew

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/b6953a3e-3392-445e-ab07-bf900b80e9c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple IP address on same VM

Alvaro Miranda Aguilera
Hello

in linux, when you have a network card you should use a single network card for each segment, having 2 nics on the same segment can cause weird things with routing to other networks.

the linux way to put more than one 1 in the same network is create aliases in the network.

say you have eth1 then you can have eth1:0 eth1:1 etc.
Vagrant can have more than 1 nic on the same network, just is not what one should do.

this works:

hosts = [

  { name: 'wcs_local_env',      hostname: 'wcs.testlab',  username: 'vagrant',  ip: ['192.168.11.69','192.168.11.70'], mbox: 'centos/7', },

]

Vagrant.configure("2") do |config|

  hosts.each do |host|

    config.vm.define host[:name] do |c|

         c.vm.box = host[:mbox]

         c.vm.hostname = host[:hostname]


          host[:ip].each_with_index do |ipadr, i|

            c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0'   

          end

    end

  end

end



On Thu, Nov 30, 2017 at 8:08 PM, Mathew Abraham <[hidden email]> wrote:
Hi guys,

I'm bit new to Vagrant and struggling to configure a VM with two network interface using host network configuration. Single static IP address is working fine. I'm using following code. 
I can see IP 192.168.11.69 defined in ifconfig but not 192.168.11.70 ??

OS image is RHEL 7.2


hosts = [
  { name: 'wcs_local_env',      hostname: 'wcs.testlab',  username: 'vagrant',  ip: ['192.168.11.69','192.168.11.70'], mbox: 'rhel64Node', },
]
Vagrant.configure("2") do |config|

  hosts.each do |host|
    config.vm.define host[:name] do |c|
         c.vm.box = host[:box]
         c.vm.hostname = host[:hostname]
    
          host[:ip].each_with_index do |ipadr, i|
          
            if i > 0
               c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0', :adapter => i
            else
               c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0'  
            end 
         
          end 

Thanks,
Mathew

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/b6953a3e-3392-445e-ab07-bf900b80e9c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CAHqq0exNWHTjxfs4zr1E7bbSGxNafZb9Vn6VVsM0ezzRcH-b3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple IP address on same VM

Mathew Abraham
Thanks Alvaro,

That worked perfectly I can now see 2 IP  appearing..!

On Thursday, November 30, 2017 at 9:04:47 PM UTC, Alvaro Miranda Aguilera wrote:
Hello

in linux, when you have a network card you should use a single network card for each segment, having 2 nics on the same segment can cause weird things with routing to other networks.

the linux way to put more than one 1 in the same network is create aliases in the network.

say you have eth1 then you can have eth1:0 eth1:1 etc.
Vagrant can have more than 1 nic on the same network, just is not what one should do.

this works:

hosts = [

  { name: 'wcs_local_env',      hostname: 'wcs.testlab',  username: 'vagrant',  ip: ['192.168.11.69','192.168.11.70'], mbox: 'centos/7', },

]

Vagrant.configure("2") do |config|

  hosts.each do |host|

    config.vm.define host[:name] do |c|

         c.vm.box = host[:mbox]

         c.vm.hostname = host[:hostname]


          host[:ip].each_with_index do |ipadr, i|

            c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0'   

          end

    end

  end

end



On Thu, Nov 30, 2017 at 8:08 PM, Mathew Abraham <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="2NBS4k-qAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">logicth...@...> wrote:
Hi guys,

I'm bit new to Vagrant and struggling to configure a VM with two network interface using host network configuration. Single static IP address is working fine. I'm using following code. 
I can see IP 192.168.11.69 defined in ifconfig but not 192.168.11.70 ??

OS image is RHEL 7.2


hosts = [
  { name: 'wcs_local_env',      hostname: 'wcs.testlab',  username: 'vagrant',  ip: ['192.168.11.69','192.168.11.70'], mbox: 'rhel64Node', },
]
Vagrant.configure("2") do |config|

  hosts.each do |host|
    config.vm.define host[:name] do |c|
         c.vm.box = host[:box]
         c.vm.hostname = host[:hostname]
    
          host[:ip].each_with_index do |ipadr, i|
          
            if i > 0
               c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0', :adapter => i
            else
               c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0'  
            end 
         
          end 

Thanks,
Mathew

--
This mailing list is governed under the HashiCorp Community Guidelines - <a href="https://www.hashicorp.com/community-guidelines.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.hashicorp.com%2Fcommunity-guidelines.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGHa_CaKfZaJiwbkUndUQbVGlQCDw&#39;;return true;">https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: <a href="https://github.com/mitchellh/vagrant/issues" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fmitchellh%2Fvagrant%2Fissues\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHxcA5DuHlQlPInMi_k1Pz4pMNqNw&#39;;return true;">https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="2NBS4k-qAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">vagrant-up+...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/vagrant-up/b6953a3e-3392-445e-ab07-bf900b80e9c7%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/b6953a3e-3392-445e-ab07-bf900b80e9c7%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/vagrant-up/b6953a3e-3392-445e-ab07-bf900b80e9c7%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/vagrant-up/b6953a3e-3392-445e-ab07-bf900b80e9c7%40googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.



--
Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/da87c3a6-340f-4289-bb72-43a8c87f1127%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple IP address on same VM

Mathew Abraham
In reply to this post by Mathew Abraham


On Thursday, November 30, 2017 at 7:08:47 PM UTC, Mathew Abraham wrote:
Hi guys,

I'm bit new to Vagrant and struggling to configure a VM with two network interface using host network configuration. Single static IP address is working fine. I'm using following code. 
I can see IP 192.168.11.69 defined in ifconfig but not 192.168.11.70 ??

OS image is RHEL 7.2


hosts = [
  { name: 'wcs_local_env',      hostname: 'wcs.testlab',  username: 'vagrant',  ip: ['192.168.11.69','192.168.11.70'], mbox: 'rhel64Node', },
]
Vagrant.configure("2") do |config|

  hosts.each do |host|
    config.vm.define host[:name] do |c|
         c.vm.box = host[:box]
         c.vm.hostname = host[:hostname]
    
          host[:ip].each_with_index do |ipadr, i|
          
            if i > 0
               c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0', :adapter => i
            else
               c.vm.network :private_network, ip: ipadr, netmask: '255.255.255.0'  
            end 
         
          end 

Thanks,
Mathew

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/dc65b94e-087d-4477-94d9-14f080d82354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.