kernel: image: linuxkit/kernel:4.19.104 cmdline: "console=ttyS0 root=/dev/sda1 root=/dev/sr0 adlin.token=LqCdJDfniA" # cmdline: "console=tty0" init: - linuxkit/init:a4fcf333298f644dfac6adf680b83140927aa85e - linuxkit/runc:69b4a35eaa22eba4990ee52cccc8f48f6c08ed03 - linuxkit/containerd:09553963ed9da626c25cf8acdf6d62ec37645412 - linuxkit/ca-certificates:v0.7 - linuxkit/getty:v0.7 onboot: - name: format image: linuxkit/format:65b9e0a76d0b9fb8ac5c5f3bc8d3131109290f56 command: ["/usr/bin/format", "/dev/sda"] - name: mount image: linuxkit/mount:v0.7 command: ["/usr/bin/mountie", "/dev/sda1", "/var/lib/adlin"] - name: sysctl image: linuxkit/sysctl:v0.7 binds: - /etc/sysctl.d/:/etc/sysctl.d/:ro - name: rngd1 image: linuxkit/rngd:02c555b50cd1887aa628836662d2eec54c0d7e81 command: ["/sbin/rngd", "-1"] # Network: external - name: dhcpcd image: linuxkit/dhcpcd:v0.7 command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1", "eth0"] net: new runtime: interfaces: - name: eth0 bindNS: net: /run/netns/router services: - name: dhcpcd-wks1 image: linuxkit/dhcpcd:v0.7 hostname: wks1 net: new pid: new ipc: new uts: new runtime: interfaces: - name: eth1 - name: ethwks1 bindNS: net: /run/netns/wks1 uts: /run/utsns/wks1 - name: dhcpcd-wks2 image: linuxkit/dhcpcd:v0.7 hostname: wks2 net: new pid: new ipc: new uts: new runtime: interfaces: - name: ethwks2 bindNS: net: /run/netns/wks2 uts: /run/utsns/wks2 - name: sshd-wks1 image: linuxkit/sshd:v0.7 net: /run/netns/wks1 uts: /run/utsns/wks1 pid: new ipc: new binds: - /etc/ssh/sshd_config:/etc/ssh/sshd_config - /etc/wpasswd:/etc/passwd - /etc/wshadow:/etc/shadow - name: sshd-wks2 image: linuxkit/sshd:v0.7 net: /run/netns/wks2 uts: /run/utsns/wks2 pid: new ipc: new binds: - /etc/ssh/sshd_config:/etc/ssh/sshd_config - /etc/wpasswd:/etc/passwd - /etc/wshadow:/etc/shadow - name: mainrouter image: nemunaire/adlin-tuto3:a8593e91cb830dede2ad25a205ef47141a5a3c22 net: /run/netns/router pid: new ipc: new uts: new hostname: router command: ["/sbin/init"] capabilities: - all mounts: - type: cgroup options: ["rw","nosuid","noexec","nodev","relatime"] binds: - /etc/hosts:/etc/hosts:ro - /etc/dresolv.conf:/etc/resolv.conf - name: matrix image: nemunaire/tinydeb:eaa617bf726fb4cadfa22b3947709579e6001212 net: /run/netns/chat pid: new ipc: new uts: new hostname: matrixsrv command: ["/sbin/init"] capabilities: - all mounts: - type: cgroup options: ["rw","nosuid","noexec","nodev","relatime"] binds: - /etc/hosts:/etc/hosts:ro - /etc/dresolv.conf:/etc/resolv.conf - name: ns-resolv image: nemunaire/unbound:ed3ccbb5340aefd48c53a97743fdc6edc7011103 net: /run/netns/ns pid: new ipc: new uts: new hostname: resolvsrv capabilities: - all binds: - /etc/unbound:/etc/unbound:ro - /etc/services:/etc/services:ro - name: ns-auth image: nemunaire/nsd:b96e6b002e08afd42e4c77ee71766264c42cac57 net: /run/netns/ns-auth pid: new ipc: new uts: new hostname: nsauthsrv capabilities: - all mounts: - type: cgroup options: ["rw","nosuid","noexec","nodev","relatime"] binds: - /var/lib/adlin/nsd:/etc/nsd:rw - /var/lib/adlin/nsd-db:/var/db/nsd:rw - /etc/nsd:/etc/nsd.sample:ro - /etc/network:/etc/network:ro - /etc/services:/etc/services:ro - /etc/dresolv.conf:/etc/resolv.conf runtime: mkdir: - /var/lib/adlin/nsd - /var/lib/adlin/nsd-db - name: db image: postgres:alpine net: /run/netns/db pid: new ipc: new uts: new hostname: db capabilities: - all env: - LANG=en_US.utf8 - PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/" - PGDATA=/var/lib/postgresql/data - POSTGRES_PASSWORD=adlin2021 binds: - /etc/services:/etc/services:ro - /initdb/:/docker-entrypoint-initdb.d/:ro - /var/lib/adlin/postgres:/var/lib/postgresql/data runtime: mkdir: - /var/lib/adlin/postgres # - name: chat # image: nemunaire/mattermost:ecb81e668c64d07b4453f9b465a6998fc6ceb067-dirty # net: /run/netns/chat # capabilities: # - all # command: ["/entrypoint.sh", "/mattermost/bin/platform"] # env: # - MM_USERNAME=mattermost # - MM_DBNAME=mattermost # - MM_PASSWORD=adlin2021 # binds: # - /etc/services:/etc/services:ro # - /etc/hosts:/etc/hosts:ro - name: miniflux image: miniflux/miniflux:latest net: /run/netns/ttrss uts: new pid: new ipc: new hostname: miniflux capabilities: - all command: ["/bin/sh", "-c", "sleep 5; /usr/bin/miniflux"] env: - DATABASE_URL=postgres://miniflux:adlin2021@db/miniflux?sslmode=disable - RUN_MIGRATIONS=1 - CREATE_ADMIN=1 - ADMIN_USERNAME=adeline - ADMIN_PASSWORD=adlin2021 - LISTEN_ADDR=0.0.0.0:8080 binds: - /etc/hosts:/etc/hosts:ro - /etc/dresolv.conf:/etc/resolv.conf - /etc/services:/etc/services:ro - name: web image: nemunaire/tinydeb:eaa617bf726fb4cadfa22b3947709579e6001212 net: /run/netns/web pid: new ipc: new uts: new hostname: vitrine command: ["/sbin/init"] capabilities: - all mounts: - type: cgroup options: ["rw","nosuid","noexec","nodev","relatime"] binds: - /etc/dresolv.conf:/etc/resolv.conf files: - path: etc/hosts contents: | 127.0.0.1 localhost ::1 localhost 172.23.42.2 ns 172.23.42.3 ns-auth 172.23.42.4 db 172.23.42.5 matrix 172.23.42.6 news 172.23.42.7 web mode: "0444" - path: usr/bin/ask.sh source: pkg/wg/ask.sh mode: "0755" - path: /root/feeds.opml source: feeds.opml mode: "0444" - path: etc/ssh/sshd_config source: pkg/nsd/sshd_config mode: "0644" - path: /usr/bin/reset-router-firewall contents: | #!/bin/sh PS=$(pgrep systemd | head -1) nsenter -t "${PS}" -a iptables -F nsenter -t "${PS}" -a iptables -P INPUT ACCEPT nsenter -t "${PS}" -a iptables -P FORWARD ACCEPT nsenter -t "${PS}" -a iptables -P OUTPUT ACCEPT nsenter -t "${PS}" -a iptables -t nat -F mode: "0755" - path: /usr/sbin/wg contents: | nsenter -n/run/netns/router /usr/bin/wg $@ mode: "0755" - path: /initdb/init-miniflux.sh contents: | #!/bin/sh set -e psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL CREATE USER miniflux WITH PASSWORD 'adlin2021'; CREATE DATABASE miniflux; GRANT ALL PRIVILEGES ON DATABASE miniflux TO miniflux; EOSQL psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname miniflux <<-EOSQL CREATE EXTENSION hstore; EOSQL mode: "0555" - path: /initdb/init-matrix.sql contents: | CREATE USER matrix WITH PASSWORD 'adlin2021'; CREATE DATABASE matrix; GRANT ALL PRIVILEGES ON DATABASE matrix TO matrix; mode: "0444" - path: etc/init.d/011-tuto-net contents: | #!/bin/sh mkdir -p /var/lib/adlin/wireguard/ nsenter -n/run/netns/router /usr/bin/ask.sh # Network: workstations ip link add ethwks type veth peer name veth-wks ip link set ethwks up ip link set ethwks netns router ip netns exec router ip a add 192.168.6.254/24 dev ethwks grep MyIPv6= /var/lib/adlin/wireguard/adlin.conf > /dev/null && ip netns exec router ip a add $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#1::1/96#") dev ethwks # Network: servers ip link add ethsrv type veth peer name veth-srv ip link set ethsrv netns router ip netns exec router ip link set ethsrv up ip netns exec router ip a add 172.23.42.1/24 dev ethsrv grep MyIPv6= /var/lib/adlin/wireguard/adlin.conf > /dev/null && ip netns exec router ip a add $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:1/96#") dev ethsrv ip netns add ns ip link add vethin-ns type veth peer name veth-ns ip link set vethin-ns netns ns ip netns exec ns ip link set vethin-ns up ip netns exec ns ip a add 172.23.42.2/24 dev vethin-ns ip netns exec ns ip route add default via 172.23.42.1 grep MyIPv6= /var/lib/adlin/wireguard/adlin.conf > /dev/null && { ip netns exec ns ip a add $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:2/96#") dev vethin-ns ip netns exec ns ip route add default via $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:1#") } ip netns add ns-auth ip link add vethin-nsauth type veth peer name veth-nsauth ip link set vethin-nsauth netns ns-auth ip netns exec ns-auth ip link set lo up ip netns exec ns-auth ip link set vethin-nsauth up ip netns exec ns-auth ip a add 172.23.42.3/24 dev vethin-nsauth ip netns exec ns-auth ip route add default via 172.23.42.1 grep MyIPv6= /var/lib/adlin/wireguard/adlin.conf > /dev/null && { ip netns exec ns-auth ip a add $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:3/96#") dev vethin-nsauth ip netns exec ns-auth ip route add default via $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:1#") } ip netns add db ip link add vethin-db type veth peer name veth-db ip link set vethin-db netns db ip netns exec db ip link set vethin-db up ip netns exec db ip a add 172.23.42.4/24 dev vethin-db ip netns exec db ip route add default via 172.23.42.1 grep MyIPv6= /var/lib/adlin/wireguard/adlin.conf > /dev/null && { ip netns exec db ip a add $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:4/96#") dev vethin-db ip netns exec db ip route add default via $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:1#") } ip netns add chat ip link add vethin-chat type veth peer name veth-chat ip link set vethin-chat netns chat ip netns exec chat ip link set vethin-chat up ip netns exec chat ip a add 172.23.42.5/24 dev vethin-chat ip netns exec chat ip route add default via 172.23.42.1 grep MyIPv6= /var/lib/adlin/wireguard/adlin.conf > /dev/null && { ip netns exec chat ip a add $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:5/96#") dev vethin-chat ip netns exec chat ip route add default via $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:1#") } ip netns add ttrss ip link add vethin-ttrss type veth peer name veth-ttrss ip link set vethin-ttrss netns ttrss ip netns exec ttrss ip link set vethin-ttrss up ip netns exec ttrss ip a add 172.23.42.6/24 dev vethin-ttrss ip netns exec ttrss ip route add default via 172.23.42.1 grep MyIPv6= /var/lib/adlin/wireguard/adlin.conf > /dev/null && { ip netns exec ttrss ip a add $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:6/96#") dev vethin-ttrss ip netns exec ttrss ip route add default via $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:1#") } ip netns add web ip link add vethin-web type veth peer name veth-web ip link set vethin-web netns web ip netns exec web ip link set vethin-web up ip netns exec web ip a add 172.23.42.7/24 dev vethin-web ip netns exec web ip route add default via 172.23.42.1 grep MyIPv6= /var/lib/adlin/wireguard/adlin.conf > /dev/null && { ip netns exec web ip a add $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:7/96#") dev vethin-web ip netns exec web ip route add default via $(sed 's/^.*MyIPv6=//p;d' /var/lib/adlin/wireguard/adlin.conf | sed "s#:[^:/]*/.*\$#:1#") } # Network: bridges ip l add brsrv type bridge ip link set veth-srv master brsrv ip link set veth-ns master brsrv ip link set veth-nsauth master brsrv ip link set veth-db master brsrv ip link set veth-chat master brsrv ip link set veth-ttrss master brsrv ip link set veth-web master brsrv ip link set veth-srv up ip link set veth-ns up ip link set veth-nsauth up ip link set veth-db up ip link set veth-chat up ip link set veth-ttrss up ip link set veth-web up ip link set brsrv up ip l add brwks type bridge ip link add veth-wks1 type veth peer name ethwks1 ip link add veth-wks2 type veth peer name ethwks2 ip link set veth-wks master brwks ip link set veth-wks1 master brwks ip link set veth-wks2 master brwks ip link set veth-wks up ip link set veth-wks1 up ip link set veth-wks2 up ip link set brwks up ip l | grep eth2 > /dev/null && { ip link set eth2 up ip link set eth2 master brwks } mode: "0755" - path: /etc/init.d/999-rw-passwd.sh contents: | #!/bin/sh sed -ri '/^root/s@^.*$@root:$6$QNuPvO59Xk4UO3le$3P0V2ef6dHlKgO1FHsKcPPgOvL.YeCOPFqfIVTtpYn5eEn3xkgGYeM1RMCQ9l/eTc6rRc.l.WeRe1iJVznVGj/:17968:0:99999:7:::@' /containers/services/mainrouter/rootfs/etc/shadow cp /etc/services /containers/services/mainrouter/rootfs/etc/services sed -ri '/^root/s@^.*$@root:$6$QNuPvO59Xk4UO3le$3P0V2ef6dHlKgO1FHsKcPPgOvL.YeCOPFqfIVTtpYn5eEn3xkgGYeM1RMCQ9l/eTc6rRc.l.WeRe1iJVznVGj/:17968:0:99999:7:::@' /containers/services/matrix/rootfs/etc/shadow cp /etc/services /containers/services/matrix/rootfs/etc/services sed -ri '/^root/s@^.*$@root:$6$QNuPvO59Xk4UO3le$3P0V2ef6dHlKgO1FHsKcPPgOvL.YeCOPFqfIVTtpYn5eEn3xkgGYeM1RMCQ9l/eTc6rRc.l.WeRe1iJVznVGj/:17968:0:99999:7:::@' /containers/services/ns-auth/rootfs/etc/shadow cp /etc/services /containers/services/web/rootfs/etc/services sed -ri '/^root/s@^.*$@root:$6$QNuPvO59Xk4UO3le$3P0V2ef6dHlKgO1FHsKcPPgOvL.YeCOPFqfIVTtpYn5eEn3xkgGYeM1RMCQ9l/eTc6rRc.l.WeRe1iJVznVGj/:17968:0:99999:7:::@' /containers/services/web/rootfs/etc/shadow exit 0 mode: "0555" - path: /etc/init.d/999-import-feeds.sh contents: | #!/bin/sh sleep 20 nsenter -t $(pgrep systemd | head -1) -a curl -s -u adeline:adlin2021 -d @- http://172.23.42.6:8080/v1/import < /root/feeds.opml 2> /dev/null > /dev/null exit 0 mode: "0555" - path: etc/issue.adlin source: pkg/debian-tuto3/issue mode: "0444" - path: /etc/init.d/500-showip.sh contents: | #!/bin/sh echo cat /etc/issue.adlin echo nsenter -n/run/netns/router ip -c a show dev wg0 2> /dev/null || echo "You didn't define your token to connect the network. Please run here `join-p0m` and then reboot." nsenter -n/run/netns/router ip -c a show dev eth0 nsenter -n/run/netns/wks1 ip -c a show dev eth1 2> /dev/null || echo "Attachez une seconde carte ethernet à la VM pour pouvoir vous connecter à un poste de travail." exit 0 mode: "0555" # - path: /etc/init.d/999-getty.sh # contents: | # #!/bin/sh # while true # do # /usr/bin/setsid /usr/bin/nsenter -t $(echo $(ps a | grep sshd | head -1) | cut -d ' ' -f 1) -m -u -n -p -- /sbin/agetty -l /sbin/login 38400 tty1 linux # sleep 1 # done & # mode: "0555" - path: /usr/bin/welcome contents: | #!/bin/sh /etc/init.d/500-showip.sh mode: "0755" - path: /usr/sbin/sos-dhcp contents: | #!/bin/sh nsenter -t $(pgrep dhcpcd) -a dhcpcd mode: "0755" - path: /usr/sbin/raz-my-dd contents: | #!/bin/sh echo -n "Are you sure? Press Enter to continue... " read -s dd if=/dev/zero of=/dev/sda size=10 bs=4096 sync reboot -f mode: "0755" - path: /usr/sbin/join-p0m contents: | #!/bin/sh [ -s "/var/lib/adlin/wireguard/adlin.token" ] && echo "A token is already defined. You'll erase it it you continue." echo -n "Please copy your token here: " read WGTOKEN mkdir -p /var/lib/adlin/wireguard/ echo $WGTOKEN > /var/lib/adlin/wireguard/adlin.token echo "Token saved. You need to reboot now." mode: "0755" - path: etc/network/interfaces contents: | auto lo iface lo inet manual mode: "0440" - path: etc/nsd/nsd.conf contents: | remote-control: control-enable: yes zone: name: login-x.srs.p0m.fr zonefile: /etc/nsd/login-x.srs.p0m.fr.zone mode: "0644" - path: etc/nsd/login-x.srs.p0m.fr.zone contents: | login-x.srs.p0m.fr. 900 SOA ns.login-x.srs.p0m.fr. root.login-x.srs.p0m.fr. 2020032900 172800 3600 2419200 86400 login-x.srs.p0m.fr. 900 NS ns.login-x.srs.p0m.fr. ns.login-x.srs.p0m.fr. 900 AAAA 2a01:e0a:2b:2252:4242::3 mode: "0644" - path: etc/unbound/unbound.conf contents: | server: verbosity: 1 interface: 0.0.0.0 interface: ::0 prefer-ip6: no access-control: 172.23.0.0/16 allow access-control: 192.168.0.0/16 allow log-queries: yes log-replies: yes use-syslog: no hide-identity: yes hide-version: yes qname-minimisation: yes domain-insecure: "." val-permissive-mode: yes trust-anchor-file: "/usr/share/dnssec-root/trusted-key.key" local-zone: "adlin.p0m.fr" typetransparent local-data: "news.adlin.p0m.fr A 172.23.42.1" local-data: "matrix.adlin.p0m.fr A 172.23.42.1" local-data: "www.adlin.p0m.fr A 172.23.42.1" remote-control: control-enable: no forward-zone: name: "." forward-addr: 9.9.9.9 forward-addr: 2606:4700:4700::1111 mode: "0440" - path: etc/wpasswd contents: | root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin sys:x:3:3:sys:/dev:/usr/sbin/nologin sync:x:4:65534:sync:/bin:/bin/sync games:x:5:60:games:/usr/games:/usr/sbin/nologin man:x:6:12:man:/var/cache/man:/usr/sbin/nologin lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin mail:x:8:8:mail:/var/mail:/usr/sbin/nologin news:x:9:9:news:/var/spool/news:/usr/sbin/nologin uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin proxy:x:13:13:proxy:/bin:/usr/sbin/nologin www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin backup:x:34:34:backup:/var/backups:/usr/sbin/nologin list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin _apt:x:100:65534::/nonexistent:/bin/false sshd:x:102:65534::/run/sshd:/usr/sbin/nologin systemd-timesync:x:103:105:systemd Time Synchronization,,,:/run/systemd:/bin/false systemd-network:x:104:106:systemd Network Management,,,:/run/systemd/netif:/bin/false systemd-resolve:x:105:107:systemd Resolver,,,:/run/systemd/resolve:/bin/false systemd-bus-proxy:x:106:108:systemd Bus Proxy,,,:/run/systemd:/bin/false mode: "0644" - path: etc/wshadow contents: | root:$6$QNuPvO59Xk4UO3le$3P0V2ef6dHlKgO1FHsKcPPgOvL.YeCOPFqfIVTtpYn5eEn3xkgGYeM1RMCQ9l/eTc6rRc.l.WeRe1iJVznVGj/:17968:0:99999:7::: daemon:*:17575:0:99999:7::: bin:*:17575:0:99999:7::: sys:*:17575:0:99999:7::: sync:*:17575:0:99999:7::: games:*:17575:0:99999:7::: man:*:17575:0:99999:7::: lp:*:17575:0:99999:7::: mail:*:17575:0:99999:7::: news:*:17575:0:99999:7::: uucp:*:17575:0:99999:7::: proxy:*:17575:0:99999:7::: www-data:*:17575:0:99999:7::: backup:*:17575:0:99999:7::: list:*:17575:0:99999:7::: irc:*:17575:0:99999:7::: gnats:*:17575:0:99999:7::: nobody:*:17575:0:99999:7::: _apt:*:17575:0:99999:7::: sshd:*:17594:0:99999:7::: systemd-timesync:*:17594:0:99999:7::: systemd-network:*:17594:0:99999:7::: systemd-resolve:*:17594:0:99999:7::: systemd-bus-proxy:*:17594:0:99999:7::: mode: "0640" - path: etc/dresolv.conf contents: | nameserver 172.23.42.2 mode: "0644" - path: var/lib/adlin directory: true mode: "0755" - path: etc/mresolv.conf contents: | nameserver 9.9.9.9 nameserver 2606:4700:4700::1111 nameserver 1.1.1.1 nameserver 2620:fe::fe mode: "0644" trust: org: - linuxkit - library