]> ruderich.org/simon Gitweb - linux-network-namespace-labs/linux-network-namespace-labs.git/commitdiff
Enable IPv4/IPv6 forwarding for nodes
authorSimon Ruderich <simon@ruderich.org>
Fri, 1 Nov 2024 07:51:37 +0000 (08:51 +0100)
committerSimon Ruderich <simon@ruderich.org>
Fri, 1 Nov 2024 07:51:37 +0000 (08:51 +0100)
This tool is focused on network labs which almost always require
routing.

main.go

diff --git a/main.go b/main.go
index 5c1e9cc91a50b8a16c28d1a67bedaa50ec232e7a..6e3f1e19348fd4b03e1392a8b41f6858a48c74b8 100644 (file)
--- a/main.go
+++ b/main.go
@@ -62,6 +62,10 @@ func main() {
                        log.Fatal(err)
                }
 
+               // Enable IPv4 and IPv6 forwarding
+               ip("netns", "exec", ns, "sysctl", "-q", "net.ipv4.ip_forward=1")
+               ip("netns", "exec", ns, "sysctl", "-q", "net.ipv6.conf.all.forwarding=1")
+
                ip("-n", ns, "link", "set", "lo", "up")
                // Extra interface for our loopback addresses; keeping them separate
                // can make things easier (e.g. using the interface for protocols).