{"id":17552349,"url":"https://github.com/saschpe/libvirt-hook-qemu","last_synced_at":"2025-05-16T11:03:45.543Z","repository":{"id":14720994,"uuid":"17441607","full_name":"saschpe/libvirt-hook-qemu","owner":"saschpe","description":"Libvirt hook for setting up iptables port-forwarding rules when using NAT-ed networking.","archived":false,"fork":false,"pushed_at":"2025-01-17T08:17:50.000Z","size":61,"stargazers_count":243,"open_issues_count":13,"forks_count":69,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-04-09T06:06:18.017Z","etag":null,"topics":["json","json-schema","libvirt","nat","port-forwarding","python"],"latest_commit_sha":null,"homepage":"","language":"Python","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/saschpe.png","metadata":{"files":{"readme":"README.rst","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":"2014-03-05T13:33:02.000Z","updated_at":"2025-03-24T02:45:35.000Z","dependencies_parsed_at":"2024-12-29T22:28:47.759Z","dependency_job_id":"1a27d642-0fd8-4a24-a6db-c086b5ff8aa9","html_url":"https://github.com/saschpe/libvirt-hook-qemu","commit_stats":{"total_commits":67,"total_committers":15,"mean_commits":4.466666666666667,"dds":0.791044776119403,"last_synced_commit":"f0c941cfc7a86fdd6364d3b15daea972d9c6ab4f"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saschpe%2Flibvirt-hook-qemu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saschpe%2Flibvirt-hook-qemu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saschpe%2Flibvirt-hook-qemu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saschpe%2Flibvirt-hook-qemu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saschpe","download_url":"https://codeload.github.com/saschpe/libvirt-hook-qemu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518383,"owners_count":22084374,"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":["json","json-schema","libvirt","nat","port-forwarding","python"],"created_at":"2024-10-21T05:04:03.759Z","updated_at":"2025-05-16T11:03:45.510Z","avatar_url":"https://github.com/saschpe.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":".. image:: https://travis-ci.org/saschpe/libvirt-hook-qemu.svg?branch=master\n    :target: https://travis-ci.org/saschpe/libvirt-hook-qemu\n\nLibvirt port-forwarding hook\n============================\n\nLibvirt hook for setting up iptables port-forwarding rules when using NAT-ed\nnetworking.\n\n\nInstallation\n------------\n\nTo install the hook script and it's configuration files, simply use the\nMakefile_:\n\n.. code-block:: bash\n\n    $ sudo make install\n\nRestart your libvirt daemon after installing:\n\n.. code-block:: bash\n\n    $ sudo service libvirtd restart\n\nAfterwards, customize ``/etc/libvirt/hooks/hooks.json`` to your needs.\nThe file includes documentation on how to set up the port forwards, but\nchanges to the file will be reflected only when the guest VM stops and starts again.\n\nThe Makefile target can be invoked multiple times, already installed\nconfiguration files won't be touched. The files can be removed again with:\n\n.. code-block:: bash\n\n    $ sudo make uninstall\n\nTesting\n-------\n\nTo run unit tests use the ``test`` target of the Makefile_:\n\n.. code-block:: bash\n\n    $ make test\n\nOr use the Python unittest module to discover tests directly:\n\n.. code-block:: python\n\n    python -m unittest discover\n\n\nNetworking\n----------\n\nThis section describes the theory behind the generated iptables statements.\n\nPackets arriving on the public interface are DNATed to the virtual machine.\nThis implements the actual port-forwarding.  Due to the way iptables is\nimplemented, the DNAT must occur in two chains: nat:PREROUTING for packets\narriving on the public interface, and nat:OUTPUT for packets originating on\nthe host.\n\nWe also add rules to the FORWARD chain to ensure the responses return.\n\nFinally, packets originating on the guest and sent to the host's public IP\naddress need special handling.  They are DNATed back to the guest like all\nother packets but, because the destination is now the same as the source,\nthe reply never leaves the guest.  Therefore, the host SNATs these packets\nto ensure the reply returns over the bridge.\n\nTo see a real-world example, the ``test_setup`` function in test_qemu.py_\ndemonstrates a simple JSON configuration and the iptables rules that it produces.\n\n\nAuthors\n-------\n\n- Sascha Peilicke\n- Scott Bronson\n\n\n.. _Makefile: Makefile\n.. _test_qemu.py: test_qemu.py\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaschpe%2Flibvirt-hook-qemu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaschpe%2Flibvirt-hook-qemu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaschpe%2Flibvirt-hook-qemu/lists"}