APPPUNTI VM internet e AMPRNET: differenze tra le versioni
Riga 195: | Riga 195: | ||
DNS=8.8.8.8 | DNS=8.8.8.8 | ||
Domains=~. | Domains=~. | ||
</pre> | |||
Test configurazione '''da rivedere''' | |||
<pre> | |||
root@geu-ampr:~# resolvectl status | |||
</pre> | |||
<pre> | |||
Global | |||
Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported | |||
resolv.conf mode: stub | |||
Current DNS Server: 8.8.8.8 | |||
DNS Servers 44.32.32.2 44.60.44.3 44.32.32.1 8.8.8.8 | |||
DNS Domain ampr.ari.it ~. | |||
Link 2 (ens18) | |||
Current Scopes: LLMNR/IPv4 LLMNR/IPv6 | |||
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported | |||
DNS Domain: DOMAINS | |||
Link 3 (wg_ampr_ari) | |||
Current Scopes: none | |||
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported | |||
</pre> | </pre> | ||
Versione delle 18:54, 6 mar 2024
Appunti di viaggio per gli addetti ai lavori
WORK IN PROGRESS
Vm di base
Questa è una VM debian minimal su OVH che ha una configurazione di rete MOLTO particolare. Se funziona qui, ci sono altissime probabilità che funioni anche da voi.
La VM nasce con connettività internet del provider di hosting. Si vuole ottenere che un servizio di rete venga erogato verso internet se richiesto da internet e verso la 44 se richiesto da AMPR.
Pacchetti base installalti: iptables ipset wireguard ssh caddy
interfacce
root@geu-ampr:/etc/network# cat interfaces
source /etc/network/interfaces.d/* auto lo iface lo inet loopback allow-hotplug eth0 iface eth0 inet static address ip.in.ter.net/32 post-up ip route add gw.in.ter.net dev eth0 post-up ip route add default via gw.in.ter.net dev eth0 pre-down ip route del default via gw.in.ter.net dev eth0 pre-down ip route del gw.in.ter.net dev eth0
tunnel wireguard
root@geu-ampr:/etc/wireguard# cat wg_ampr_ari0.conf
[Peer] PublicKey = PUBLICKEY AllowedIPs = 44.0.0.0/9, 44.128.0.0/10 Endpoint = 5.144.187.34:13236 PresharedKey = PRESHAREDKEY [Interface] ListenPort = 51820 PrivateKey = PRIVATEKEY Address = 44.32.33.xxx/21 # Se si usa questa riga DNS, tutte le richieste dns verranno dirottate li. Usare systemd-resolved per avere un risolutore specifico per dominio #DNS = 44.32.32.2, 44.60.44.3, 44.32.32.1 # Creare riga "585 r_AMPR" in /etc/iproute2/rt_tables Table = r_AMPR PostUp = /etc/wireguard/wg_ampr_ari-up0.sh
root@geu-ampr:/etc/wireguard# cat wg_ampr_ari0-up.sh
#!/bin/bash ip route del 44.0.0.0/9 via 44.32.32.1 >/dev/null ||true ip route del 44.128.0.0/10 via 44.32.32.1 >/dev/null ||true ip route add 44.0.0.0/9 via 44.32.32.1 ip route add 44.128.0.0/10 via 44.32.32.1 ip route del 44.0.0.0/9 via 44.32.32.1 dev wg_ampr_ari0 table r_AMPR >/dev/null |true ip route del 44.128.0.0/10 via 44.32.32.1 dev wg_ampr_ari0 table r_AMPR >/dev/null |true ip route add 44.0.0.0/9 via 44.32.32.1 dev wg_ampr_ari0 table r_AMPR ip route add 44.128.0.0/10 via 44.32.32.1 dev wg_ampr_ari0 table r_AMPR
Abilitazione del servizio per l'avvio automatico:
systemctl enable wg-quick@wg_ampr_ari0.service systemctl start wg-quick@wg_ampr_ari0
Test instradamento
Test instradamento verso internet OK
traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets 1 551.255.69.252 (551.255.69.252) 0.505 ms 0.508 ms 0.669 ms 2 510.17.50.50 (510.17.50.50) 0.521 ms 0.618 ms 0.697 ms 3 510.73.17.66 (510.73.17.66) 0.199 ms 4 510.95.64.136 (510.95.64.136) 0.574 ms 5 * * * 6 510.200.2.69 (10.200.2.69) 3.965 ms 3.929 ms 7 * * * 8 * * * 9 66.249.94.133 (66.249.94.133) 4.942 ms dns.google (8.8.8.8) 4.100 ms 142.250.234.43 (142.250.234.43) 4.897 ms
Test instradamento verso AMPR ARI OK
traceroute 44.32.32.2
traceroute to 44.32.32.2 (44.32.32.2), 30 hops max, 60 byte packets 1 44.32.32.1 (44.32.32.1) 25.891 ms 25.864 ms 25.882 ms 2 44.32.32.2 (44.32.32.2) 28.531 ms 28.537 ms 28.528 ms
Test instradamento verso AMPR fuori da AMR ARI FALLITO rivedere perchè
traceroute 44.88.0.9
traceroute to 44.88.0.9 (44.88.0.9), 30 hops max, 60 byte packets 1 51.255.69.252 (51.255.69.252) 0.573 ms 0.635 ms 0.829 ms 2 10.17.50.58 (10.17.50.58) 0.420 ms 10.17.50.50 (10.17.50.50) 0.496 ms 10.17.50.56 (10.17.50.56) 0.414 ms 3 10.73.16.112 (10.73.16.112) 0.242 ms 10.73.16.114 (10.73.16.114) 0.206 ms 10.73.17.64 (10.73.17.64) 0.185 ms 4 10.95.64.158 (10.95.64.158) 0.663 ms 0.416 ms 10.95.64.156 (10.95.64.156) 0.522 ms 5 lon-thw-sbb1-nc5.uk.eu (54.36.50.240) 4.296 ms 4.535 ms 4.240 ms 6 nyc-ny1-sbb1-8k.nj.us (192.99.146.127) 82.450 ms nyc-ny1-sbb2-8k.nj.us (192.99.146.133) 73.537 ms lon-thw-sbb1-nc5.uk.eu (54.36.50.240) 4.281 ms 7 nyc-ny1-sbb1-8k.nj.us (192.99.146.127) 77.398 ms be102.bhs-g1-nc5.qc.ca (198.27.73.204) 83.989 ms 81.534 ms 8 be102.bhs-g1-nc5.qc.ca (198.27.73.204) 83.947 ms be101.chi-ch2-sbb1-8k.il.us (198.27.73.207) 101.642 ms be101.chi-ch2-sbb2-8k.il.us (192.99.146.141) 94.279 ms 9 be101.chi-ch2-sbb1-8k.il.us (198.27.73.207) 99.965 ms 10.200.4.208 (10.200.4.208) 94.478 ms * 10 * * 10.200.3.193 (10.200.3.193) 153.552 ms 11 eqix-sv5.cenic.com (206.223.117.118) 144.400 ms 152.549 ms 10.200.3.193 (10.200.3.193) 149.355 ms 12 eqix-sv5.cenic.com (206.223.117.118) 147.728 ms dc-svl-agg8--svl-agg10-300g.cenic.net (137.164.11.81) 162.321 ms * 13 * dc-lax-agg8--svl-agg8--100ge--2.cenic.net (137.164.11.20) 152.430 ms dc-svl-agg8--svl-agg10-300g.cenic.net (137.164.11.81) 163.969 ms 14 dc-lax-agg8--svl-agg8--100ge--2.cenic.net (137.164.11.20) 157.846 ms dc-tus-agg8--lax-agg8-300g.cenic.net (137.164.11.83) 154.862 ms dc-lax-agg8--svl-agg8--100ge--2.cenic.net (137.164.11.20) 158.459 ms 15 dc-tus-agg8--lax-agg8-300g.cenic.net (137.164.11.83) 154.960 ms sand1-agg-01--tus-agg8--300g--01.cenic.net (137.164.11.85) 159.300 ms 154.293 ms 16 ucsd--sand1-agg-01--100g--01.cenic.net (137.164.23.177) 162.148 ms sand1-agg-01--tus-agg8--300g--01.cenic.net (137.164.11.85) 153.691 ms 153.621 ms 17 ucsd--sand1-agg-01--100g--01.cenic.net (137.164.23.177) 157.586 ms * 160.222 ms 18 * * * 19 sdsc-7710-7--mcore-vl2995-p2p.ucsd.edu (132.239.255.50) 152.531 ms 152.202 ms * 20 * * * 21 * * *
firewall
Oltre ad iptables viene usato il pacchetto iptables-persistnet che salva in /etc/iptables le regole e le attiva all'avvio.
root@geu-ampr:/etc/iptables# cat rules.v4
# Generated by iptables-save v1.8.9 (nf_tables) on Wed Mar 6 14:11:24 2024 *mangle :PREROUTING ACCEPT [0:0] :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] COMMIT # Completed on Wed Mar 6 14:11:24 2024 # Generated by iptables-save v1.8.9 (nf_tables) on Wed Mar 6 14:11:24 2024 *filter :INPUT DROP [79:8052] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [118:18860] -A INPUT -i lo -j ACCEPT -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT -A INPUT -p udp -m udp --dport 51820 -j ACCEPT -m comment --comment "WireGuard" -A INPUT -p icmp --icmp-type destination-unreachable/source-quench -j ACCEPT -m comment --comment "PMTU Discovery" -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/s --limit-burst 10 -j ACCEPT -m comment --comment "ping si ma non troppo" -A INPUT -p icmp --icmp-type echo-request -m limit --limit 1/m --limit-burst 1 -j LOG --log-prefix "ICMP flood scampato: " -A INPUT -p icmp --icmp-type echo-request -j DROP -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT -A INPUT -s ip.qth -m comment --comment "Casa" -j ACCEPT COMMIT # Completed on Wed Mar 6 14:11:24 2024
Attivazione/ripristino delle regole di firewall
iptables-restore </etc/iptables/rules.v4
Salvataggio delle regole di firewall
Se si fanno dei cambiamenti a mano da riga di comando direttamente con iptables, occorre salvarle per ritrovarsele attive dopo un riavvio.
iptables-save >/etc/iptables/rules.v4
NS resolver selettivo
Resolver di default e resolver specifico per dominio e sottodomini di ampr.ari.it
root@geu-ampr:/etc/systemd/resolved.conf.d# cat ampr.ari.it.conf
[Resolve] Domains=ampr.ari.it DNS=44.32.32.2 44.60.44.3 44.32.32.1
root@geu-ampr:/etc/systemd/resolved.conf.d# cat dns_servers.conf
[Resolve] DNS=8.8.8.8 Domains=~.
Test configurazione da rivedere
root@geu-ampr:~# resolvectl status
Global Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported resolv.conf mode: stub Current DNS Server: 8.8.8.8 DNS Servers 44.32.32.2 44.60.44.3 44.32.32.1 8.8.8.8 DNS Domain ampr.ari.it ~. Link 2 (ens18) Current Scopes: LLMNR/IPv4 LLMNR/IPv6 Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported DNS Domain: DOMAINS Link 3 (wg_ampr_ari) Current Scopes: none Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
reverse proxy
root@geu-ampr:/etc/caddy# cat Caddyfile
vm.iw1geu.ampr.ari.it:80 { root * /var/www/vm.iw1geu.ampr.ari.it file_server } my.ip.ampr.net:80 { root * /var/www/my.ip.ampr.net file_server } ip.in.ter.net:80 { root * /var/www/ip.in.ter.net file_server } :80 { respond "Makkè quarzo vuoi!??" }