From 8bfa034f337434d30bbc5688c8e858db3181cba6 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Fri, 21 Feb 2025 01:20:18 +0100 Subject: [PATCH] =?UTF-8?q?AP=20for=20clients=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machines/loc1ap/attach.sh | 6 ++++++ machines/loc1ap/opts.shs | 3 +++ machines/loc1ap/run-shim.sh | 7 +++++++ machines/loc1ap/setup.sh | 25 +++++++++++++++++++++++++ machines/loc1ap/start.sh | 12 ++++++++++++ machines/loc1gw/start.sh | 2 +- networks/loc1_cli/up.sh | 5 +++++ 7 files changed, 59 insertions(+), 1 deletion(-) create mode 100755 machines/loc1ap/attach.sh create mode 100644 machines/loc1ap/opts.shs create mode 100755 machines/loc1ap/run-shim.sh create mode 100755 machines/loc1ap/setup.sh create mode 100755 machines/loc1ap/start.sh create mode 100755 networks/loc1_cli/up.sh diff --git a/machines/loc1ap/attach.sh b/machines/loc1ap/attach.sh new file mode 100755 index 0000000..9d0b686 --- /dev/null +++ b/machines/loc1ap/attach.sh @@ -0,0 +1,6 @@ +#!/bin/sh +set -eu +. ./lib.shs +. machines/$mach/opts.shs + +nsenter --wdns=$nethorror_root $namespaces "$@" diff --git a/machines/loc1ap/opts.shs b/machines/loc1ap/opts.shs new file mode 100644 index 0000000..f0998ef --- /dev/null +++ b/machines/loc1ap/opts.shs @@ -0,0 +1,3 @@ +#!/bin/false + +namespaces="--net=./state/$mach/netns --mount=./state/$mach/mntns" diff --git a/machines/loc1ap/run-shim.sh b/machines/loc1ap/run-shim.sh new file mode 100755 index 0000000..2f42dd8 --- /dev/null +++ b/machines/loc1ap/run-shim.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -eu +. ./lib.shs + +ensure_started +attach machines/$mach/setup.sh diff --git a/machines/loc1ap/setup.sh b/machines/loc1ap/setup.sh new file mode 100755 index 0000000..3427428 --- /dev/null +++ b/machines/loc1ap/setup.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -eu + +. ./lib.shs + +# typically: bring up the networks +ip link set dev lo up + +setup_for_router + +# ISP network +ip addr add 10.0.0.2/24 dev isp_ve +# NAT: use 10.0.0.0/24 inside the network and 192.168.0.1/24 for the client network +nft add table ip nat +nft add chain ip nat postrouting { type nat hook postrouting priority srcnat \; } +nft add rule ip nat postrouting oifname \"isp_ve\" ip saddr 192.168.0.0/24 masquerade +ip link set dev isp_ve up +ip route add default via 10.0.0.1 dev isp_ve + +# network for clients +ip addr add 192.168.0.1/24 dev cli_vwlan +# No IPv6 at public spaces lol +ip link set dev cli_vwlan up + +# TODO: DHCP server! diff --git a/machines/loc1ap/start.sh b/machines/loc1ap/start.sh new file mode 100755 index 0000000..ef45631 --- /dev/null +++ b/machines/loc1ap/start.sh @@ -0,0 +1,12 @@ +#!/bin/sh +set -eu +. ./lib.shs +. machines/$mach/opts.shs + +setup_statedir + +unshare $namespaces /bin/true # just create the namespaces + +veth_to_bridge isp_ve loc1_ap ve_loc1ap_ap +# TODO: make it virt_wifi (need to read iproute2 src…) +veth_to_bridge cli_vwlan loc1_cli ve_loc1_wifi diff --git a/machines/loc1gw/start.sh b/machines/loc1gw/start.sh index 4fddaf5..afae425 100755 --- a/machines/loc1gw/start.sh +++ b/machines/loc1gw/start.sh @@ -8,4 +8,4 @@ setup_statedir unshare $namespaces /bin/true # just create the namespaces veth_to_bridge up_ve loc1_up ve_loc1up_gw -veth_to_bridge ap_ve loc1_ap +veth_to_bridge ap_ve loc1_ap ve_loc1ap_gw diff --git a/networks/loc1_cli/up.sh b/networks/loc1_cli/up.sh new file mode 100755 index 0000000..19c7ca2 --- /dev/null +++ b/networks/loc1_cli/up.sh @@ -0,0 +1,5 @@ +#!/bin/sh +set -eu + +. ./lib.shs +make_bridge