{"id":18000909,"url":"https://github.com/abbbi/vagrant-libvirt-dns","last_synced_at":"2025-04-04T08:11:45.837Z","repository":{"id":74744871,"uuid":"148653849","full_name":"abbbi/vagrant-libvirt-dns","owner":"abbbi","description":"How to manage DNS in your vagrant environment the libvirt way","archived":false,"fork":false,"pushed_at":"2018-09-13T17:59:22.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T19:17:04.618Z","etag":null,"topics":["dhcp","dhcp-server","dns","dnsmasq","documentation","libvirt","manual","vagrant"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abbbi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-13T14:53:24.000Z","updated_at":"2023-08-25T09:58:45.000Z","dependencies_parsed_at":"2023-07-11T16:34:22.849Z","dependency_job_id":null,"html_url":"https://github.com/abbbi/vagrant-libvirt-dns","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbbi%2Fvagrant-libvirt-dns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbbi%2Fvagrant-libvirt-dns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbbi%2Fvagrant-libvirt-dns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abbbi%2Fvagrant-libvirt-dns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abbbi","download_url":"https://codeload.github.com/abbbi/vagrant-libvirt-dns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142077,"owners_count":20890653,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dhcp","dhcp-server","dns","dnsmasq","documentation","libvirt","manual","vagrant"],"created_at":"2024-10-29T23:15:19.109Z","updated_at":"2025-04-04T08:11:45.820Z","avatar_url":"https://github.com/abbbi.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"About\n=========\n\nThere are various ways to manage your vagrant machines hostnames and IP\naddresses.  Most of them require you to install additional vagrant plugins (\nlandrush, hostmanager, vagrant-dns)\n\nOne of them is vagrant-landrush, which works nicely but has problems in multi\nuser environments (spinning up an DNS Service for each vagrant vm)\n\nThis short manual should give you an easier way to setup DNS and DHCP\nmanagement of your Vagrant environment with libvirt backend.\n\n\nGoal\n-------------\n\nThe goal is to have a round robin style DNS and DHCP assignment for your\nvagrant virtual machines. All machines should get an hostname from the dhcp\nservice and shall be resolvable forward and reverse from the host system aswell\nas the other vagrant machines running.\n\nAs example, lets say we have an dhcp range that goes from:\n\n 10.1.0.3   to  10.1.0.5\n\nand want those ips to be associated with hostnames like:\n\n```\n sep003.mycloud.local -\u003e 10.1.0.3\n sep004.mycloud.local -\u003e 10.1.0.4\n sep005.mycloud.local -\u003e 10.1.0.5\n```\n\nThese should match the ip given by the dhcp lease. The lease disappears as the\nvagrant machine halts and can be re-used likewise by other machines.\n\nIt should be possible doing this without the need of third party plugins just\nby modifying our libvirt network configuration. \n\nPrerequisites\n-------------\n\nYour vagrant boxes must honor DHCP's \"hostname\" option and allow to set the\nsystems hostname via DHCP client for better integration.\n\n\nConfiguring Libvirt\n-------------\n\nDefine a new libvirt network from the provided example using:\n\n```\nvirsh net-define examplenet.xml\n```\n\nNote: you may have to assign a special bridge name in the config file to\navaoid libvirt re-using an existing one.\n\n```\n \u003cbridge name='virbrXX' stp='on' delay='0'/\u003e\n```\n\nAnd start the network:\n\n```\nvirsh net-start my_cloud\n```\n\nThis should spin up a new libvirt network with its according dnsmasq process:\n\n```\n$ ps axw | grep my_cloud\n11714 ?        S      0:00 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/my_cloud.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper\n\n```\n\nThe example provides a lease range for three possible IP's and hostnames.\n\nSpinning up vagrant box\n-------------\n\nNow initialize a new Vagrant box (this example uses debian9):\n\n```\nvagrant init generic/debian9\n```\n\nAnd edit your Vagantfile to contain the following section:\n\n```\n  config.vm.provider :libvirt do |domain|\n        domain.management_network_name = \"my_cloud\"\n        domain.management_network_address = \"10.1.0.0/24\"\n  end\n```\n\nFollowed by:\n\n```\nvagrant up\n```\n\nAs the VM starts, it receives its dhcp lease and hostname from the dnsmasq\nservice:\n\n```\n~$ virsh net-dhcp-leases my_cloud\n Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID\n-------------------------------------------------------------------------------------------------------------------\n 2018-09-13 18:10:58  52:54:00:02:7b:cb  ipv4      10.1.0.4/24               sep004   \n```\n\nGetting into the box the hostname should have been set too:\n\n```\n~/mynet$ vagrant ssh\n[..]\nvagrant@sep004:~$ \n```\n\nAs all boxes use the local dnsmasq dns server, other boxes can happily\nforward and reverse lookup each other:\n\n```\n~/mynet-2$ vagrant ssh\n[..]\nvagrant@sep003:~$ host sep004\nsep004.mycloud.local has address 10.1.0.4\nvagrant@sep003:~$ host 10.1.0.4\n4.0.1.10.in-addr.arpa domain name pointer sep004.mycloud.local.\n```\n\nConfiguring the Hostsystem\n-------------\nIn order to make the host system aware of the hostnames and domain you have to make\nyour system wide dnsmasq aware of the libvirt dnsmasq server. Place the provided example \nfile in:\n\n```\n/etc/dnsmasq.d/my-cloud.local\n```\n\nAnd reload your dnsmasq service. Now the hostsystem should be able to resolve your\nvagrant boxes aswell:\n\n```\nvagrantuser@hostsystem:~$ host sep003.mycloud.local\nsep003.mycloud.local has address 10.1.0.3\n```\n\nFreeing leases\n-------------\n\nLeases are automatically freed as the vagrant box is halted:\n\n```\n:~/mynet$ vagrant halt\n==\u003e default: Halting domain...\n~/mynet$ virsh net-dhcp-leases my_cloud\n Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID\n-------------------------------------------------------------------------------------------------------------------\n 2018-09-13 18:14:17  52:54:00:16:ee:ab  ipv4      10.1.0.3/24               sep003          -\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabbbi%2Fvagrant-libvirt-dns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabbbi%2Fvagrant-libvirt-dns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabbbi%2Fvagrant-libvirt-dns/lists"}