{"id":25241302,"url":"https://github.com/gruyaume/router","last_synced_at":"2026-05-02T19:31:43.011Z","repository":{"id":289547617,"uuid":"971599010","full_name":"gruyaume/router","owner":"gruyaume","description":"An eBPF based router (experimental)","archived":false,"fork":false,"pushed_at":"2025-04-24T00:14:12.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T01:23:26.033Z","etag":null,"topics":["ebpf","networking","router","xdp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gruyaume.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-23T19:08:03.000Z","updated_at":"2025-04-24T00:14:14.000Z","dependencies_parsed_at":"2025-04-24T01:23:29.689Z","dependency_job_id":null,"html_url":"https://github.com/gruyaume/router","commit_stats":null,"previous_names":["gruyaume/xdp-tutorial","gruyaume/router"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gruyaume/router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruyaume%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruyaume%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruyaume%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruyaume%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gruyaume","download_url":"https://codeload.github.com/gruyaume/router/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gruyaume%2Frouter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32547645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T19:18:06.202Z","status":"ssl_error","status_checked_at":"2026-05-02T19:16:21.335Z","response_time":132,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ebpf","networking","router","xdp"],"created_at":"2025-02-11T21:02:22.645Z","updated_at":"2026-05-02T19:31:43.005Z","avatar_url":"https://github.com/gruyaume.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Router\n\n**A fast eBPF-based router for Linux**\n\nThis is mostly exploratory code, and not intended for production use.\n\n## Tutorials\n\n### Installing Router on 1 host using network namespaces\n\n#### 1. Install Pre-requisites\n\n```shell\nsudo snap install go --channel=1.24/stable --classic\nsudo apt update\nsudo apt -y install clang llvm gcc-multilib libbpf-dev\n```\n\n#### 2. Create environment\n\n```shell\n# 1. Create namespaces\nfor ns in hostA router hostB; do\n  sudo ip netns add $ns\n  sudo ip netns exec $ns ip link set lo up\ndone\n\n# 2. Create veths\nsudo ip link add vethA type veth peer name vethR1\nsudo ip link add vethB type veth peer name vethR2\n\nsudo ip link set vethA netns hostA\nsudo ip link set vethR1 netns router\nsudo ip link set vethB netns hostB\nsudo ip link set vethR2 netns router\n\n# 3. Assign addresses \u0026 bring up\nsudo ip netns exec hostA ip addr add 10.0.0.1/24 dev vethA\nsudo ip netns exec hostA ip link set vethA up\n\nsudo ip netns exec router ip addr add 10.0.0.254/24 dev vethR1\nsudo ip netns exec router ip link set vethR1 up\n\nsudo ip netns exec hostB ip addr add 10.1.0.1/24 dev vethB\nsudo ip netns exec hostB ip link set vethB up\n\nsudo ip netns exec router ip addr add 10.1.0.254/24 dev vethR2\nsudo ip netns exec router ip link set vethR2 up\n\nsudo ip netns exec hostA ip route add 10.1.0.0/24 via 10.0.0.254 dev vethA\nsudo ip netns exec hostB ip route add 10.0.0.0/24 via 10.1.0.254 dev vethB\n```\n\n#### 3. Build and run the project\n\n```shell\ngo build cmd/router/main.go\nsudo ip netns exec router ./main --config router.yaml\n```\n\n### Installing Router and validating it using Multipass\n\n#### 1. Create environment\n\nCreate three LXD networks:\n\n```shell\nlxc network create net1 ipv4.address=10.0.0.1/24 ipv4.routing=false\nlxc network create net2 ipv4.address=20.0.0.1/24 ipv4.routing=false\n```\n\nCreate three Multipass instances:\n\n```shell\nmultipass launch noble --name=host1 --network net1\nmultipass launch noble --name=host2 --network net2\nmultipass launch noble --name=router --network net1 --network net2\n```\n\nValidate that the 3 instances have been created:\n\n```shell\nmultipass list\n```\n\nYou should see the following output:\n\n```shell\nName                    State             IPv4             Image\nhost1                   Running           10.166.86.124    Ubuntu 24.04 LTS\n                                          10.0.0.144\nhost2                   Running           10.166.86.61     Ubuntu 24.04 LTS\n                                          20.0.0.41\nrouter                  Running           10.166.86.122    Ubuntu 24.04 LTS\n                                          10.0.0.130\n                                          20.0.0.12\n```\n\n#### 2. Create routes in host1 and host2 towards the router VM\n\nConnect to host1:\n\n```shell\nmultipass shell host1\n```\n\nCreate a route to host2:\n\n```shell\nsudo ip route add 20.0.0.0/24 via 10.0.0.130 dev ens4\n```\n\nTry to ping host2:\n\n```shell\nping -I ens4 20.0.0.41\n```\n\nYou should see that the ping fails.\n\nExit the shell:\n\n```shell\nexit\n```\n\nLog into host2:\n\n```shell\nmultipass shell host2\n```\n\nCreate a route to host1:\n\n```shell\nsudo ip route add 10.0.0.0/24 via 20.0.0.12 dev ens4\n```\n\nExit the shell:\n\n```shell\nexit\n```\n\n#### 3. Build and run the project\n\nLog into the router:\n\n```shell\nmultipass shell router\n```\n\nBuild the project:\n\n```shell\nsudo snap install go --channel=1.24/stable --classic\nsudo apt update\nsudo apt -y install clang llvm gcc-multilib libbpf-dev\ngit clone https://github.com/gruyaume/router.git\ncd router\ngo build cmd/router/main.go\n```\n\nWrite the configuration file:\n\n```shell\ncat \u003c\u003c EOF \u003e router.yaml\ninterfaces: [\"ens4\", \"ens5\"]\nroutes:\n  - destination: \"10.0.0.144\"\n    prefixlen: 24\n    interface: \"ens4\"\n    gateway: \"0.0.0.0\"\n  - destination: \"20.0.0.41\"\n    prefixlen: 24\n    interface: \"ens5\"\n    gateway: \"0.0.0.0\"\nneighbors:\n  - ip: \"10.0.0.144\"\n    mac: \"52:54:00:e1:7b:38\"\n  - ip: \"20.0.0.41\"\n    mac: \"52:54:00:86:fe:fd\"\nlog_level: \"info\"\nEOF\n```\n\nRun the router:\n\n```shell\nsudo ./main --config router.yaml\n```\n\n## Reference\n\n### Configuration file\n\nRouter is configured using a YAML file. \n\nStart Router with the `--config` flag to specify the path to the configuration file.\n\n#### Parameters\n\n- `interfaces` (list[string]): List of interfaces to be used by the router. The eBPF program will be attached to all of them.\n- `routes` (list[route]): List of routes to be added to the routing table. Each route is defined by:\n  - `destination` (string): The destination IP address.\n  - `prefixlen` (int): The prefix length of the destination IP address.\n  - `interface` (string): The interface to use for this route.\n  - `gateway` (string): The gateway IP address for this route.\n- `neighbors` (list[neighbor]): List of neighbors to be added to the ARP table. Each neighbor is defined by:\n  - `ip` (string): The IP address of the neighbor.\n  - `mac` (string): The MAC address of the neighbor.\n\n#### Example\n\n```yaml\ninterfaces: [\"vethR1\", \"vethR2\"]\nroutes:\n  - destination: \"10.1.0.1\"\n    prefixlen: 32\n    interface: \"vethR2\"\n    gateway: \"0.0.0.0\"\n  - destination: \"10.0.0.1\"\n    prefixlen: 32\n    interface: \"vethR1\"\n    gateway: \"0.0.0.0\"\nneighbors:\n  - ip: \"10.0.0.1\"\n    mac: \"c6:9f:fb:e6:cc:1f\"\n  - ip: \"10.1.0.1\"\n    mac: \"8a:93:d5:28:9e:35\"\nlog_level: \"info\"\n```\n\n### Performance\n\nUsing the Multipass setup, I am able to achieve **over 3 Gbps throughput** between host1 and host2, going through the router.\n\n```shell\nubuntu@host1:~$ iperf3 -c 20.0.0.41 --bind-dev ens4\nConnecting to host 20.0.0.41, port 5201\n[  5] local 10.0.0.144 port 33702 connected to 20.0.0.41 port 5201\n[ ID] Interval           Transfer     Bitrate         Retr  Cwnd\n[  5]   0.00-1.00   sec   403 MBytes  3.37 Gbits/sec  509    520 KBytes       \n[  5]   1.00-2.00   sec   404 MBytes  3.39 Gbits/sec  302    457 KBytes       \n[  5]   2.00-3.00   sec   404 MBytes  3.39 Gbits/sec  151    687 KBytes       \n[  5]   3.00-4.00   sec   435 MBytes  3.65 Gbits/sec   81    940 KBytes       \n[  5]   4.00-5.00   sec   417 MBytes  3.50 Gbits/sec  247    433 KBytes       \n[  5]   5.00-6.00   sec   403 MBytes  3.38 Gbits/sec  156    496 KBytes       \n[  5]   6.00-7.00   sec   416 MBytes  3.49 Gbits/sec  164    550 KBytes       \n[  5]   7.00-8.00   sec   403 MBytes  3.38 Gbits/sec  331    369 KBytes       \n[  5]   8.00-9.00   sec   420 MBytes  3.53 Gbits/sec    0    882 KBytes       \n[  5]   9.00-10.00  sec   394 MBytes  3.31 Gbits/sec  305    393 KBytes       \n- - - - - - - - - - - - - - - - - - - - - - - - -\n[ ID] Interval           Transfer     Bitrate         Retr\n[  5]   0.00-10.00  sec  4.00 GBytes  3.44 Gbits/sec  2246             sender\n[  5]   0.00-10.00  sec  4.00 GBytes  3.44 Gbits/sec                  receiver\n\niperf Done.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruyaume%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgruyaume%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgruyaume%2Frouter/lists"}