commit 47a0e7763bdbd3274e3676974478fd627eb2f430
parent a4606e297bf17d5250e76d9942d5f048f1d482de
Author: Leah Thein <leah@toaster.home.ctu.cx>
Date: Tue, 8 Dec 2020 00:27:36 +0100
parent a4606e297bf17d5250e76d9942d5f048f1d482de
Author: Leah Thein <leah@toaster.home.ctu.cx>
Date: Tue, 8 Dec 2020 00:27:36 +0100
move alpine stuff to sub-directory
111 files changed, 250 insertions(+), 227 deletions(-)
A
|
96
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A
|
78
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
R
|
0
R
|
0
D
|
88
-------------------------------------------------------------------------------
diff --git a/.DS_Store b/.DS_Store Binary files differ.
diff --git a/alpine/.DS_Store b/alpine/.DS_Store Binary files differ.
diff --git a/alpine/config-files/ferm/ferm-lollo.conf b/alpine/config-files/ferm/ferm-lollo.conf @@ -0,0 +1,95 @@ +# -*- shell-script -*- +# +# Ferm example script +# +# Firewall configuration for a router with a dynamic IP. +# +# Author: Max Kellermann <max@duempel.org> +# + +@def $DEV_LAN = brlan0; +@def $DEV_WAN = eth0; + +@def $NET_LAN = 10.0.0.0/24; + +# globally accessible services +@def $WAN_TCP = ( 22 ); +@def $WAN_UDP = ( 1194 ); +# ( ssh ) +# ( wireguard ) + +# locally accessible services +@def $LAN_TCP = ( 53 22 ); +@def $LAN_UDP = ( 53 67 69 123 ); +# ( dns ssh ) +# ( dns dhcp tftp ntp ) + +# generic input and forwarding rules for ipv4 and ipv6 +domain (ip ip6) { + table filter { + chain INPUT { + policy DROP; + + # connection tracking + mod state state INVALID DROP; + mod state state (ESTABLISHED RELATED) ACCEPT; + + # allow local connections + interface lo ACCEPT; + + # respond to ping + proto ipv6-icmp icmpv6-type redirect DROP; + proto ipv6-icmp icmpv6-type 139 DROP; + proto ipv6-icmp ACCEPT; + proto icmp ACCEPT; + + # local services + interface ! $DEV_WAN { + proto tcp dport $LAN_TCP ACCEPT; + proto udp mod multiport destination-ports $LAN_UDP ACCEPT; + } + + proto tcp dport $WAN_TCP ACCEPT; + proto udp dport $WAN_UDP ACCEPT; + } + + # outgoing connections are not limited + chain OUTPUT policy ACCEPT; + + chain FORWARD { + policy DROP; + + # connection tracking + mod state state INVALID DROP; + mod state state (ESTABLISHED RELATED) ACCEPT; + + # local clients can do whatever + interface $DEV_LAN ACCEPT; + + + proto icmp ACCEPT; + + mod conntrack ctstate DNAT ACCEPT; + + # the rest is dropped by the above policy + } + } +} + +# nat only for ipv4 +domain ip { + table nat { + chain PREROUTING { + policy ACCEPT; + + # port forwards, ala daddr $WAN_IP dport 65522 DNAT to 192.168.0.2:22; + } + + chain POSTROUTING { + policy ACCEPT; + + outerface $DEV_WAN MASQUERADE; + saddr $NET_LAN mod conntrack ctstate DNAT MASQUERADE; # needle point loopback + } + } +}+ \ No newline at end of file
diff --git a/alpine/inventory b/alpine/inventory @@ -0,0 +1,12 @@ +[all:vars] +ansible_ssh_user=root + +[taurus] +taurus.ctu.cx + + +[wanderduene] +wanderduene.ctu.cx + +[lollo] +10.0.0.1
diff --git a/alpine/playbook-router.yml b/alpine/playbook-router.yml @@ -0,0 +1,77 @@ +--- +- hosts: all + remote_user: root + gather_facts: false + tasks: + - name: Install Python + raw: test -e /usr/bin/python || (apk update && apk add python3) + +- hosts: lollo + name: Install lollo + roles: + - common + - dnsmasq +# - hostapd +# - syncthing +# - frp + vars: + alpineVersion: v3.12 + users: + - name: leah + groups: "wheel" + password: "$6$foobar123$1qcCmnoveirSdWY9XdgH5hCXv32hj0n/AyJX46sSp1LyGCA8QT/xxifebRxr89uIH6vwhzFGgz4.H2sG0en0f0" + sshKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCw/G6x8H3ojvHx3NsTswBMMmOhp48F3rea0GUniKSvRLMRIti5b7Q4P4FXnkQEtuNSR3u7gE5r4EacaLaIx7Az9SgHRoE+hdzSo4mPAwKTx/E3HZgIjdZhTDL8PAn4SZZT6RBqr/uGb+x9fdIjY0FbdNBLjq0MNnG3T+qd1joUL8JXoS7F//ac52RhHlsA5qJXFDOhpqR/7hRMwOFNH0GKaLN1xQKcOjhpIcdswpOf8kRDVpT7xOYwfXCFF4MaY2M8047WKarvEnGdADIIw6bvWsdJINehtOQmYEFRaMuaWp1d9bglZXZKPQKNubv5lqneMP4AI7ImDYjgW6eNLIT1 cardno:000603502829" + network: + hostname: lollo + domain: ctu.cx + nameservers: + - 1.1.1.1 + - 8.8.8.8 + useFerm: true + useAwall: false + vlanSupport: true + natSupport: true + bridgeSupport: true + interfaces: + - name: lo + loopback: true + - name: eth0 + ipv4: + dhcp: true + ipv6: + stateless: true + - name: eth0.5 + manual: true + - name: brlan0 + bridge_ports: eth0.5 + bridge_stp: false + ipv4: + addresses: + - 10.0.0.1 + - 195.39.246.40 + netmask: 255.255.255.0 + ipv6: + address: 2a0f:4ac0:acab::1 + netmask: 64 + hostapd: + interface: wlan0 + bridge: brlan0 + channel: 1 + ssid: legacy.home.ctu.cx + passphrase: wasd1998 + dnsmasq: + dhcp: true + syncthing: + disableReverseProxy: true + guiAddress: 0.0.0.0:8384 + frpc: + serverAddress: wanderduene.ctu.cx + serverPort: 5050 + token: "{{ lookup('community.general.passwordstore', 'server/wanderduene/frps/token returnall=true')}}" + dashboard: false + tunnels: + - name: lollo-ssh + type: tcp + local_ip: 127.0.0.1 + local_port: 22 + remote_port: 2202+ \ No newline at end of file
diff --git a/alpine/roles/common/tasks/packages.yml b/alpine/roles/common/tasks/packages.yml @@ -0,0 +1,32 @@ +--- + +- name: get signature from personal repo + get_url: + url: http://home.f2k1.de:8080/leah-5f817de5.rsa.pub + dest: /etc/apk/keys/leah-5f817de5.rsa.pub + +- name: "Update file: /etc/apk/repositories" + template: + src: repositories.j2 + dest: /etc/apk/repositories + +- name: update system + raw: "apk update && apk upgrade" + +- name: Install common packages + apk: + name: + - nano + - sudo + - htop + - tar + - unzip + - curl + - wget + - tmux + - git + - patch + - jq + - restic + update_cache: yes +
diff --git a/alpine/roles/dnsmasq/tasks/main.yml b/alpine/roles/dnsmasq/tasks/main.yml @@ -0,0 +1,18 @@ +--- + +- name: "Install package: dnsmasq" + apk: + name: dnsmasq + state: present + update_cache: yes + +- name: "create file: /etc/dnsmasq.conf" + template: + src: dnsmasq.conf.j2 + dest: /etc/dnsmasq.d/ansible.conf + +- name: "Enable and restart service: dnsmasq" + service: + name: dnsmasq + enabled: yes + state: restarted
diff --git a/alpine/roles/wireguard/tasks/main.yml b/alpine/roles/wireguard/tasks/main.yml @@ -0,0 +1,14 @@ +--- + +- name: "Install package: wireguard-tools-wg" + apk: + name: wireguard-tools-wg + state: present + update_cache: yes + +- name: "Create directory: /etc/wireguard" + file: + path: /etc/wireguard + mode: 0700 + state: directory +
diff --git a/config-files/ferm/ferm-lollo.conf b/config-files/ferm/ferm-lollo.conf @@ -1,87 +0,0 @@ -# -*- shell-script -*- -# -# Ferm example script -# -# Firewall configuration for a router with a dynamic IP. -# -# Author: Max Kellermann <max@duempel.org> -# - -@def $DEV_LAN = brlan0; -@def $DEV_WAN = eth0; - -@def $NET_LAN = 10.0.0.0/24; - -# globally accessible services -@def $WAN_TCP = ( 22 ); -@def $WAN_UDP = ( 1194 ); -# ( ssh ) -# ( wireguard ) - -# locally accessible services -@def $LAN_TCP = ( 53 22 ); -@def $LAN_UDP = ( 53 67 69 123 ); -# ( dns ssh ) -# ( dns dhcp tftp ntp ) - -table filter { - chain INPUT { - policy DROP; - - # connection tracking - mod state state INVALID DROP; - mod state state (ESTABLISHED RELATED) ACCEPT; - - # allow local connections - interface lo ACCEPT; - - # respond to ping - proto icmp ACCEPT; - - - # local services - interface ! $DEV_WAN { - proto tcp dport $LAN_TCP ACCEPT; - proto udp mod multiport destination-ports $LAN_UDP ACCEPT; - } - - proto tcp dport $WAN_TCP ACCEPT; - proto udp dport $WAN_UDP ACCEPT; - } - - # outgoing connections are not limited - chain OUTPUT policy ACCEPT; - - chain FORWARD { - policy DROP; - - # connection tracking - mod state state INVALID DROP; - mod state state (ESTABLISHED RELATED) ACCEPT; - - # local clients can do whatever - interface $DEV_LAN ACCEPT; - - - proto icmp ACCEPT; - - mod conntrack ctstate DNAT ACCEPT; - - # the rest is dropped by the above policy - } -} - -table nat { - chain PREROUTING { - policy ACCEPT; - - # port forwards, ala daddr $WAN_IP dport 65522 DNAT to 192.168.0.2:22; - } - - chain POSTROUTING { - policy ACCEPT; - - outerface $DEV_WAN MASQUERADE; - saddr $NET_LAN mod conntrack ctstate DNAT MASQUERADE; # needle point loopback - } -}- \ No newline at end of file
diff --git a/inventory b/inventory @@ -1,12 +0,0 @@ -[all:vars] -ansible_ssh_user=root - -[taurus] -taurus.ctu.cx - - -[wanderduene] -wanderduene.ctu.cx - -[lollo] -192.168.178.116- \ No newline at end of file
diff --git a/playbook-router.yml b/playbook-router.yml @@ -1,75 +0,0 @@ ---- -- hosts: all - remote_user: root - gather_facts: false - tasks: - - name: Install Python - raw: test -e /usr/bin/python || (apk update && apk add python3) - -- hosts: lollo - name: Install lollo - roles: - - common - - dnsmasq -# - hostapd -# - syncthing -# - frp - vars: - alpineVersion: v3.12 - users: - - name: leah - groups: "wheel" - password: "$6$foobar123$1qcCmnoveirSdWY9XdgH5hCXv32hj0n/AyJX46sSp1LyGCA8QT/xxifebRxr89uIH6vwhzFGgz4.H2sG0en0f0" - sshKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCw/G6x8H3ojvHx3NsTswBMMmOhp48F3rea0GUniKSvRLMRIti5b7Q4P4FXnkQEtuNSR3u7gE5r4EacaLaIx7Az9SgHRoE+hdzSo4mPAwKTx/E3HZgIjdZhTDL8PAn4SZZT6RBqr/uGb+x9fdIjY0FbdNBLjq0MNnG3T+qd1joUL8JXoS7F//ac52RhHlsA5qJXFDOhpqR/7hRMwOFNH0GKaLN1xQKcOjhpIcdswpOf8kRDVpT7xOYwfXCFF4MaY2M8047WKarvEnGdADIIw6bvWsdJINehtOQmYEFRaMuaWp1d9bglZXZKPQKNubv5lqneMP4AI7ImDYjgW6eNLIT1 cardno:000603502829" - network: - hostname: lollo - domain: ctu.cx - nameservers: - - 1.1.1.1 - - 8.8.8.8 - useFerm: true - useAwall: false - vlanSupport: true - natSupport: true - bridgeSupport: true - interfaces: - - name: lo - loopback: true - - name: eth0 - ipv4: - dhcp: true - ipv6: - stateless: true - - name: eth0.5 - manual: true - - name: brlan0 - bridge_ports: eth0.5 - bridge_stp: false - ipv4: - address: 10.0.0.1 - netmask: 255.255.255.0 - ipv6: - address: fe80:acab::1 - netmask: 64 - hostapd: - interface: wlan0 - bridge: brlan0 - channel: 1 - ssid: legacy.home.ctu.cx - passphrase: wasd1998 - dnsmasq: - dhcp: true - syncthing: - disableReverseProxy: true - guiAddress: 0.0.0.0:8384 - frpc: - serverAddress: wanderduene.ctu.cx - serverPort: 5050 - token: "{{ lookup('community.general.passwordstore', 'server/wanderduene/frps/token returnall=true')}}" - dashboard: false - tunnels: - - name: lollo-ssh - type: tcp - local_ip: 127.0.0.1 - local_port: 22 - remote_port: 2202- \ No newline at end of file
diff --git a/roles/common/tasks/packages.yml b/roles/common/tasks/packages.yml @@ -1,31 +0,0 @@ ---- -- name: get signature from personal repo - get_url: - url: http://home.f2k1.de:8080/leah-5f817de5.rsa.pub - dest: /etc/apk/keys/leah-5f817de5.rsa.pub - -- name: "Update file: /etc/apk/repositories" - template: - src: repositories.j2 - dest: /etc/apk/repositories - -- name: update system - raw: "apk update && apk upgrade" - -- name: Install common packages - apk: - name: - - nano - - sudo - - htop - - tar - - unzip - - curl - - wget - - tmux - - git - - patch - - jq - - restic - update_cache: yes -
diff --git a/roles/dnsmasq/tasks/main.yml b/roles/dnsmasq/tasks/main.yml @@ -1,18 +0,0 @@ ---- - -- name: "Install package: dnsmasq" - apk: - name: dnsmasq - state: present - update_cache: yes - -- name: "create file: /etc/dnsmasq.d/ansible.conf" - template: - src: dnsmasq.conf.j2 - dest: /etc/dnsmasq.d/ansible.conf - -- name: "Enable and restart service: dnsmasq" - service: - name: dnsmasq - enabled: yes - state: restarted