{"id":18512829,"url":"https://github.com/vmware/network-event-broker","last_synced_at":"2025-10-25T17:14:45.347Z","repository":{"id":43375357,"uuid":"373450454","full_name":"vmware/network-event-broker","owner":"vmware","description":"manages network configuration","archived":false,"fork":false,"pushed_at":"2024-10-07T06:32:22.000Z","size":6525,"stargazers_count":24,"open_issues_count":3,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T22:14:06.528Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vmware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","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":"2021-06-03T09:23:12.000Z","updated_at":"2025-04-03T00:00:13.000Z","dependencies_parsed_at":"2023-02-12T21:01:48.244Z","dependency_job_id":"b4a7c873-16a1-48a7-8ba1-c6232916ea08","html_url":"https://github.com/vmware/network-event-broker","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/vmware/network-event-broker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fnetwork-event-broker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fnetwork-event-broker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fnetwork-event-broker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fnetwork-event-broker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vmware","download_url":"https://codeload.github.com/vmware/network-event-broker/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vmware%2Fnetwork-event-broker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280988263,"owners_count":26425486,"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","status":"online","status_checked_at":"2025-10-25T02:00:06.499Z","response_time":81,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-06T15:35:37.076Z","updated_at":"2025-10-25T17:14:45.330Z","avatar_url":"https://github.com/vmware.png","language":"Go","readme":"### network-event-broker\n----\nA daemon configures network and executes scripts on network events such as `systemd-networkd's` [DBus](https://www.freedesktop.org/wiki/Software/dbus/) events,\n`dhclient` gains lease lease. It also watches when\n\n1. An address getting added/removed/modified.\n2. Links added/removed.\n\n```network-event-broker``` creates \n\n- link state directories ```carrier.d```,  ```configured.d```,  ```degraded.d```  ```no-carrier.d```  ```routable.d``` \n-  manager state dir ```manager.d``` \n-  `routes.d` (when routes gets modfied)\n\n```bash\n╭─root@Zeus1 /etc  \n╰─➤  tree network-broker \nnetwork-broker\n├── carrier.d\n├── configured.d\n├── degraded.d\n├── manager.d\n├── network-broker.toml\n├── no-carrier.d\n```\n \nin ```/etc/network-broker```. Executable scripts can be placed into directories.\n\nUse cases:\n\nHow to run a command when get a new address is acquired via DHCP ?\n\n1. `systemd-networkd's`\n Scripts are executed when the daemon receives the relevant event from `systemd-networkd`. See [networkctl](https://www.freedesktop.org/software/systemd/man/networkctl.html).\n\n\n```bash\nMay 14 17:08:13 Zeus cat[273185]: OperationalState=\"routable\"\nMay 14 17:08:13 Zeus cat[273185]: LINK=ens33\n```\n\n2. `dhclient`\n  For `dhclient` scripts will be executed (in the dir ```routable.d```) when the `/var/lib/dhclient/dhclient.leases` file gets modified by `dhclient` and lease information is passed to the scripts as environmental arguments.\n\nEnvironment variables `LINK`, `LINKINDEX=` and DHCP lease information `DHCP_LEASE=`  passed to the scripts.\n\n#### How can I make my secondary network interface work ?\n\n When both interfaces are in same subnet and we have only one routing table with one GW, ie. traffic that reach via eth1 tries to leave via eth0(primary interface) which it can't. So we need to add a secondary routing table and routing policy so that the secondary interface uses the new custom routing table. Incase of static address the address and the routes already know. Incase of DHCP it's not predictable.  When `RoutingPolicyRules=` is set, `network-event-broker` automatically configures the routing policy rules `From` and `To` ensuring traffic reaches via eth1 leaves via eth1. \n\n#### Building from source\n----\n\n```bash\n\n❯ make build\n❯ sudo make install\n\n```\n\nDue to security `network-broker` runs in non root user `network-broker`. It drops all privileges except CAP_NET_ADMIN and CAP_SYS_ADMIN.\n\n```bash\n❯  useradd -M -s /usr/bin/nologin network-broker\n```\n\n### Configuration\n----\n\nConfiguration file `network-broker.toml` located in ```/etc/network-broker/``` directory to manage the configuration.\n\nThe `[System]` section takes following Keys:\n``` bash\n\nLogLevel=\n```\nSpecifies the log level. Takes one of `info`, `warn`, `error`, `debug` and `fatal`. Defaults to `info`.\n\n```bash\n\nGenerator= \n```\nSpecifies the network event generator source to listen. Takes one of `systemd-networkd` or `dhclient`. Defaults to `systemd-networkd`.\n\n\nThe `[Network]` section takes following Keys:\n\n```bash\n\nLinks=\n```\nA whitespace-separated list of links whose events should be monitored. Defaults to unset.\n\n```bash\n\nRoutingPolicyRules=\n```\nA whitespace-separated list of links for which routing policy rules would be configured per address. When set, `network-broker` automatically adds routing policy rules `from` and `to` in another routing table `(ROUTE_TABLE_BASE = 9999 + ifindex)`. When these addresses are removed, the routing policy rules are also dropped. Defaults to unset.\n\n```bash\nEmitJSON=\n```\nA boolean. When true, JSON format data will be emitted via envorment variable `JSON=` Applies only for `systemd-networkd`. Defaults to true.\n\n```json\n{\n  \"Index\": 3,\n  \"MTU\": 1500,\n  \"TxQLen\": 1000,\n  \"Name\": \"ens37\",\n  \"AlternativeNames\": \"\",\n  \"HardwareAddr\": \"00:0c:29:5f:d1:43\",\n  \"Flags\": \"up|broadcast|multicast\",\n  \"RawFlags\": 69699,\n  \"ParentIndex\": 0,\n  \"MasterIndex\": 0,\n  \"Namespace\": \"\",\n  \"Alias\": \"\",\n  \"Statistics\": {\n    \"RxPackets\": 573564,\n    \"TxPackets\": 373642,\n    \"RxBytes\": 540984229,\n    \"TxBytes\": 65923722,\n    \"RxErrors\": 0,\n    \"TxErrors\": 0,\n    \"RxDropped\": 0,\n    \"TxDropped\": 0,\n    \"Multicast\": 0,\n    \"Collisions\": 0,\n    \"RxLengthErrors\": 0,\n    \"RxOverErrors\": 0,\n    \"RxCrcErrors\": 0,\n    \"RxFrameErrors\": 0,\n    \"RxFifoErrors\": 0,\n    \"RxMissedErrors\": 0,\n    \"TxAbortedErrors\": 0,\n    \"TxCarrierErrors\": 0,\n    \"TxFifoErrors\": 0,\n    \"TxHeartbeatErrors\": 0,\n    \"TxWindowErrors\": 0,\n    \"RxCompressed\": 0,\n    \"TxCompressed\": 0\n  },\n  \"Promisc\": 0,\n  \"Xdp\": {\n    \"Fd\": 0,\n    \"Attached\": false,\n    \"Flags\": 0,\n    \"ProgId\": 0\n  },\n  \"EncapType\": \"ether\",\n  \"Protinfo\": \"\",\n  \"OperState\": \"up\",\n  \"NetNsID\": 0,\n  \"NumTxQueues\": 1,\n  \"NumRxQueues\": 1,\n  \"GSOMaxSize\": 65536,\n  \"GSOMaxSegs\": 65535,\n  \"Group\": 0,\n  \"Slave\": \"\",\n  \"KernelOperState\": \"up\",\n  \"AddressState\": \"routable\",\n  \"CarrierState\": \"carrier\",\n  \"Driver\": \"e1000\",\n  \"IPv4AddressState\": \"routable\",\n  \"IPv6AddressState\": \"off\",\n  \"LinkFile\": \"\",\n  \"Model\": \"82545EM Gigabit Ethernet Controller (Copper)\",\n  \"OnlineState\": \"online\",\n  \"OperationalState\": \"routable\",\n  \"Path\": \"pci-0000:02:05.0\",\n  \"SetupState\": \"configuring\",\n  \"Type\": \"ether\",\n  \"Vendor\": \"Intel Corporation\",\n  \"ProductID\": \"100f\",\n  \"Manufacturer\": \"\",\n  \"NetworkFile\": \"/etc/systemd/network/10-ens37.network\",\n  \"DNS\": [\n    \"172.16.130.2\"\n  ],\n  \"Domains\": null,\n  \"NTP\": null,\n  \"Address\": [\n    {\n      \"IP\": \"172.16.130.144\",\n      \"Mask\": 24,\n      \"Label\": \"ens37\",\n      \"Flags\": 0,\n      \"Scope\": 0,\n      \"Peer\": \"\",\n      \"Broadcast\": \"172.16.130.255\",\n      \"PreferedLft\": 1800,\n      \"ValidLft\": 1800\n    },\n    {\n      \"IP\": \"fe80::20c:29ff:fe5f:d143\",\n      \"Mask\": 64,\n      \"Label\": \"\",\n      \"Flags\": 192,\n      \"Scope\": 253,\n      \"Peer\": \"\",\n      \"Broadcast\": \"\",\n      \"PreferedLft\": 4294967295,\n      \"ValidLft\": 4294967295\n    }\n  ],\n  \"Routes\": [\n    {\n      \"Scope\": 0,\n      \"Dst\": {\n        \"IP\": \"\",\n        \"Mask\": 0\n      },\n      \"Src\": \"172.16.130.144\",\n      \"Gw\": \"172.16.130.2\",\n      \"MultiPath\": \"\",\n      \"Protocol\": 16,\n      \"Priority\": 1024,\n      \"Table\": 254,\n      \"Type\": 1,\n      \"Tos\": 0,\n      \"Flags\": null,\n      \"MPLSDst\": \"\",\n      \"NewDst\": \"\",\n      \"Encap\": \"\",\n      \"MTU\": 0,\n      \"AdvMSS\": 0,\n      \"Hoplimit\": 0\n    },\n    {\n      \"Scope\": 253,\n      \"Dst\": {\n        \"IP\": \"172.16.130.0\",\n        \"Mask\": 24\n      },\n      \"Src\": \"172.16.130.144\",\n      \"Gw\": \"\",\n      \"MultiPath\": \"\",\n      \"Protocol\": 2,\n      \"Priority\": 1024,\n      \"Table\": 254,\n      \"Type\": 1,\n      \"Tos\": 0,\n      \"Flags\": null,\n      \"MPLSDst\": \"\",\n      \"NewDst\": \"\",\n      \"Encap\": \"\",\n      \"MTU\": 0,\n      \"AdvMSS\": 0,\n      \"Hoplimit\": 0\n    },\n    {\n      \"Scope\": 253,\n      \"Dst\": {\n        \"IP\": \"172.16.130.2\",\n        \"Mask\": 32\n      },\n      \"Src\": \"172.16.130.144\",\n      \"Gw\": \"\",\n      \"MultiPath\": \"\",\n      \"Protocol\": 16,\n      \"Priority\": 1024,\n      \"Table\": 254,\n      \"Type\": 1,\n      \"Tos\": 0,\n      \"Flags\": null,\n      \"MPLSDst\": \"\",\n      \"NewDst\": \"\",\n      \"Encap\": \"\",\n      \"MTU\": 0,\n      \"AdvMSS\": 0,\n      \"Hoplimit\": 0\n    },\n    {\n      \"Scope\": 0,\n      \"Dst\": {\n        \"IP\": \"fe80::\",\n        \"Mask\": 64\n      },\n      \"Src\": \"\",\n      \"Gw\": \"\",\n      \"MultiPath\": \"\",\n      \"Protocol\": 2,\n      \"Priority\": 256,\n      \"Table\": 254,\n      \"Type\": 1,\n      \"Tos\": 0,\n      \"Flags\": null,\n      \"MPLSDst\": \"\",\n      \"NewDst\": \"\",\n      \"Encap\": \"\",\n      \"MTU\": 0,\n      \"AdvMSS\": 0,\n      \"Hoplimit\": 0\n    }\n  ]\n}\n\n```\n\n```bash\nUseDNS=\n```\nA boolean. When true, the DNS server will be se to `systemd-resolved` vis DBus. Applies only for DHClient. Defaults to false.\n\n```bash\nUseDomain=\n```\nA boolean. When true, the DNS domains will be sent to `systemd-resolved` vis DBus. Applies only for DHClient. Defaults to false.\n\n```bash\nUseHostname=\n```\nA boolean. When true, the host name be sent to `systemd-hostnamed` vis DBus. Applies only for DHClient. Defaults to false.\n\n```bash\n❯ sudo cat /etc/network-broker/network-broker.toml \n[System]\nLogLevel=\"debug\"\nGenerator=\"systemd-networkd\"\n\n[Network]\nLinks=\"eth0 eth1\"\nRoutingPolicyRules=\"eth1\"\nUseDNS=\"true\"\nUseDomain=\"true\"\nEmitJSON=\"true\"\n\n```\n\n```bash\n\n❯ systemctl status network-broker.service\n● network-broker.service - A daemon configures network upon events\n     Loaded: loaded (/usr/lib/systemd/system/network-broker.service; disabled; vendor preset: disabled)\n     Active: active (running) since Thu 2022-06-03 22:22:38 CEST; 3h 13min ago\n       Docs: man:networkd-broker.conf(5)\n   Main PID: 572392 (network-broker)\n      Tasks: 7 (limit: 9287)\n     Memory: 6.2M\n        CPU: 319ms\n     CGroup: /system.slice/network-broker.service\n             └─572392 /usr/bin/network-broker\n\nJun 04 01:36:04 Zeus network-broker[572392]: [info] 2022/06/04 01:36:04 Link='ens33' ifindex='2' changed state 'OperationalState'=\"carrier\"\nJun 04 01:36:04 Zeus network-broker[572392]: [info] 2022/06/04 01:36:04 Link='' ifindex='1' changed state 'OperationalState'=\"carrier\"\n\n```\nDBus signals generated by ```systemd-networkd```\n```bash\n\n\u0026{:1.683 /org/freedesktop/network1/link/_32 org.freedesktop.DBus.Properties.PropertiesChanged [org.freedesktop.network1.Link map[AdministrativeState:\"configured\"] []] 10}\n```\n\n```\n‣ Type=signal  Endian=l  Flags=1  Version=1 Cookie=24  Timestamp=\"Sun 2022-05-16 08:06:05.905781 UTC\"\n  Sender=:1.292  Path=/org/freedesktop/network1  Interface=org.freedesktop.DBus.Properties  Member=PropertiesChanged\n  UniqueName=:1.292\n  MESSAGE \"sa{sv}as\" {\n          STRING \"org.freedesktop.network1.Manager\";\n          ARRAY \"{sv}\" {\n                  DICT_ENTRY \"sv\" {\n                          STRING \"OperationalState\";\n                          VARIANT \"s\" {\n                                  STRING \"degraded\";\n                          };\n                  };\n          };\n          ARRAY \"s\" {\n          };\n  };\n\n```\n\n\n#### Contributing\n----\n\nThe **Network Event Broker** project team welcomes contributions from the community. If you wish to contribute code and you have not signed our contributor license agreement (CLA), our bot will update the issue when you open a Pull Request. For any questions about the CLA process, please refer to our [FAQ](https://cla.vmware.com/faq).\n\nslack channel [#photon](https://code.vmware.com/web/code/join).\n\n#### License\n----\n\n[Apache-2.0](https://spdx.org/licenses/Apache-2.0.html)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware%2Fnetwork-event-broker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvmware%2Fnetwork-event-broker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvmware%2Fnetwork-event-broker/lists"}