« Info::KVM:: Comment accéder à une VM à partir d'un réseau local (c.a.d pas à partir de la machine hôte) » : différence entre les versions

De wiki_pcwiki2
Aller à la navigationAller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 29 : Ligne 29 :
  host debian-dvt 192.168.122.134
  host debian-dvt 192.168.122.134
         # Des couleurs contrastées peuvent se trouver sur: https://app.contrast-finder.org
         # Des couleurs contrastées peuvent se trouver sur: https://app.contrast-finder.org
         localcommand xtermcontrol --bg '#FECDEE' --fg '#000000' --title="-- DEBIAN-DVT --"
         localcommand xtermcontrol --bg '#195FB2' --fg '#FFFFFF' --title="-- DEBIAN-DVT --"
         HostName 192.168.1.18
         HostName 192.168.1.18
         port    2222
         port    2222

Version du 18 septembre 2025 à 06:57

KEYWORDS: FORWARD, FORWARDING, PORT FORWARDING, KVM, QEMU, LIBVIRT

Le 18/09/2025:
Aujourd'hui, je tombe sur un problème tout bête: à partir de xps13, je ne peux pas accéder à debian-dvt en ssh ou en rsync.
La solution consiste à modifier le mur de feu de srv18 (le serveur qui héberge debian-dvt):
# Le 18/09/2025 pour accéder à debian-dvt à partir du réseau local:
# $strIptablesPath -t nat -I PREROUTING -p tcp -d 192.168.1.18  --dport 22 -j DNAT --to-destination 192.168.122.134:22
# pour SSH:
$strIptablesPath -t nat -A PREROUTING -p tcp -i enp4s0 --dport 2222 -j DNAT --to-destination 192.168.122.134:22

$strIptablesPath -A FORWARD -p tcp -d 192.168.122.134 --dport 22 -j ACCEPT
$strIptablesPath -t nat -A POSTROUTING -s 192.168.122.0/24 -o enp4s0 -j MASQUERADE
$strIptablesPath -A INPUT -i enp4s0 -p tcp --dport 2222 -j ACCEPT
$strIptablesPath -t nat -A POSTROUTING -s 192.168.122.0/24 -o enp4s0 -j MASQUERADE

# pour RSYNC
$strIptablesPath -t nat -A PREROUTING -i enp4s0 -p tcp --dport 8730 -j DNAT --to-destination 192.168.122.134:873
$strIptablesPath -A FORWARD -p tcp -d 192.168.122.134 --dport 873 -j ACCEPT
$strIptablesPath -I INPUT 1 -i enp4s0 -p tcp --dport 8730 -j ACCEPT
$strIptablesPath -t nat -A POSTROUTING -s 192.168.122.0/24 -o enp4s0 -j MASQUERADE
# apt install iptables-persistent
# iptables-save > /etc/iptables/rules.v4:
</nopre>
 
 Ensuite, 
 - Pour accéder de xps13 à debian-dvt en ssh: ssh -p 220 debian-dvt
   ou mieux encore: créer le fichier/etc/ssh/ssh_config.d/VM-debian-dvt.conf et mettre dedans:
 host debian-dvt 192.168.122.134
        # Des couleurs contrastées peuvent se trouver sur: https://app.contrast-finder.org
        localcommand xtermcontrol --bg '#195FB2' --fg '#FFFFFF' --title="-- DEBIAN-DVT --"
        HostName 192.168.1.18
        port    2222
        User root
  Dans ce dernier cas, un ssh debian-dvt suffira
 
 - Pour accéder de xps13 à debian-dvt en rsync: RSYNC_PASSWORD=billou rsync -avz --port=8730 root@192.168.1.18::RaCiNe/tmp/* .