Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [DE] iptables - portforward  (Read 165 times)

Offline hsp

  • User
  • Posts: 626
[DE] iptables - portforward
« on: 2024/04/03, 10:26:26 »
Ich habe mir nach dieser Anleitung für libvirt ein hookscript angelegt für qemu zum portforward für ssh (NAT Network). Funktioniert auch bestens. Aber was nicht geht ist eine Verbindung von localhost (ssh -p 2222 localhost). Ich habe keine Ahnung waum. Jemand eine Idee was fehlt oder falsch ist?

https://wiki.libvirt.org/Networking.html#forwarding-incoming-connections

Hier der hookscript
Code: [Select]
#!/bin/bash
#
if [ "${1}" = "foobarbox" ]; then
#
# Update the following variables to fit your setup
GUEST_IP="192.168.122.19"
GUEST_PORT="22"
HOST_PORT="2222"
BRIDGE="virbr0"
#
    if [ "${2}" = "stopped" ] || [ "${2}" = "reconnect" ]; then
        /usr/sbin/iptables -D FORWARD -o $BRIDGE -d $GUEST_IP -j ACCEPT
        /usr/sbin/iptables -t nat -D PREROUTING -p tcp --dport $HOST_PORT -j DNAT --to $GUEST_IP:$GUEST_PORT
    fi
#
    if [ "${2}" = "start" ] || [ "${2}" = "reconnect" ]; then
        /usr/sbin/iptables -I FORWARD -o $BRIDGE -d $GUEST_IP -j ACCEPT
        /usr/sbin/iptables -t nat -I PREROUTING -p tcp --dport $HOST_PORT -j DNAT --to $GUEST_IP:$GUEST_PORT
    fi
fi


Danke...

Offline hsp

  • User
  • Posts: 626
Re: iptables - portforward
« Reply #1 on: 2024/04/18, 16:16:20 »
*push*