Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not assign address to interface connected to isolated network #500

Closed
grzeniek opened this issue Dec 5, 2018 · 9 comments · Fixed by #767
Closed

Can not assign address to interface connected to isolated network #500

grzeniek opened this issue Dec 5, 2018 · 9 comments · Fixed by #767

Comments

@grzeniek
Copy link

grzeniek commented Dec 5, 2018

Version Reports:

Distro version of host:

Fedora 29

Terraform Version Report

Terraform v0.11.10

Provider and libvirt versions

terraform-provider-libvirt -version
./terraform-provider-libvirt was not built correctly
Compiled against library: libvirt 4.7.0
Using library: libvirt 4.7.0
Running hypervisor: QEMU 3.0.0
Running against daemon: 4.7.0

If that gives you "was not built correctly", get the Git commit hash from your local provider repository:

git describe --always --abbrev=40 --dirty

2ad0228349b2d3b487a2ada25d1a0eb40d73b7d1

Description of Issue/Question

When creating new isolated network of type 'none' and assigning interface to it with static address, this address is not assigned to interface.

Setup

resource "libvirt_network" "net-01" {
  name = "kube-net"
  mode = "none"
  addresses = ["10.0.1.0/24"]
  dhcp {
    enabled = false
  }
}

resource "libvirt_domain" "node-01" {
  name = "node-01"
  memory = "512"
  vcpu = 2

  network_interface {
    network_id = "${libvirt_network.net-01.id}"
    addresses = ["10.0.1.3"]
  }
@MalloZup
Copy link
Collaborator

@grzeniek you will have more infos on this issue on this comment : #441 (comment) hope it helps! 🌻

@grzeniek
Copy link
Author

Hi, thanks for info.

As I understood enabling dhcp on network net-01 should fix my problem? So I've tried this (enabling dhcp on net-01) but I couldn't get static assigned ip address on interface, it got assigned from dhcp server.

@dmacvicar
Copy link
Owner

@grzeniek May be I am missing something, but, how would configuring a static IP address from outside the VM, without assistance of the operating system network configuration, and without DHCP work?

@abbbi
Copy link
Contributor

abbbi commented Dec 20, 2018

@grzeniek for fixed ip addresses you would need the feature of defining static leases via MAC addresses, there is work beeing done garding this in PR #477

#477

@grzeniek
Copy link
Author

I thought it is possible to assign static address through 'addresses' option in network_interface definition. Now I'm doing this through cloud-init.

@arbulu89
Copy link
Contributor

arbulu89 commented Jan 3, 2019

@MalloZup As far as I understood from the last converstation, static IP assignment is not still available for private virtual networks, right? I'm not talking about dhcp, just assign an address the the desired network interface for this domain.

As vagrant does for example (check static ip):
https://www.vagrantup.com/docs/networking/private_network.html

@MalloZup
Copy link
Collaborator

MalloZup commented Jul 9, 2019

moving this feature in project plaining. We might need to investigate on it after 0.60 release

@kanekoh
Copy link

kanekoh commented Dec 26, 2019

What came of this problem? I'm facing the same issue on following environment.

  • OS: RHEL8
  • Terraform: v0.12.18
  • Provider: terraform-provider-libvirt-0.6.0

@ngyuki
Copy link
Contributor

ngyuki commented Aug 4, 2020

https://github.com/dmacvicar/terraform-provider-libvirt/blob/v0.6.2/libvirt/network_def.go#L13-L20

func HasDHCP(net libvirtxml.Network) bool {
  if net.Forward != nil {
    if net.Forward.Mode == "nat" || net.Forward.Mode == "route" || net.Forward.Mode == "" {
      return true
    }
  }
  return false
}

In isolated network, Forward is nil.
But it is possible to have a DHCP server.

Because of this, it is Can not assign fixed address by DHCP when mode = "none".

I think following fixes are needed.

 func HasDHCP(net libvirtxml.Network) bool {
   if net.Forward != nil {
     if net.Forward.Mode == "nat" || net.Forward.Mode == "route" || net.Forward.Mode == "" {
       return true
     }
+  } else {
+    // isolated network
+    return true
   }
   return false
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants