Мой скрипт хуков qemu выглядит так:
#!/bin/bash
# IMPORTANT: Change the "VM NAME" string to match your actual VM Name.
# In order to create rules to other VMs, just duplicate the below block and configure
# it accordingly.
if [ "${1}" = "win2k16" ]; then
# Update the following variables to fit your setup
GUEST_IP=192.168.122.100
GUEST_PORT=3389
HOST_PORT=49305
if [ "${2}" = "stopped" ] || [ "${2}" = "reconnect" ]; then
/sbin/iptables -D FORWARD -o virbr0 -d $GUEST_IP -j ACCEPT
/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
/sbin/iptables -I FORWARD -o virbr0 -d $GUEST_IP -j ACCEPT
/sbin/iptables -t nat -I PREROUTING -p tcp --dport $HOST_PORT -j DNAT --to $GUEST_IP:$GUEST_PORT
fi
fi
if [ "${1}" = "win2k16" ]; then
# Update the following variables to fit your setup
GUEST_IP=192.168.122.100
GUEST_PORT=25
HOST_PORT=25
if [ "${2}" = "stopped" ] || [ "${2}" = "reconnect" ]; then
/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
/sbin/iptables -t nat -I PREROUTING -p tcp --dport $HOST_PORT -j DNAT --to $GUEST_IP:$GUEST_PORT
fi
fi
if [ "${1}" = "win2k16" ]; then
# Update the following variables to fit your setup
GUEST_IP=192.168.122.100
GUEST_PORT=443
HOST_PORT=443
if [ "${2}" = "stopped" ] || [ "${2}" = "reconnect" ]; then
/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
/sbin/iptables -t nat -I PREROUTING -p tcp --dport $HOST_PORT -j DNAT --to $GUEST_IP:$GUEST_PORT
fi
fi
Моя проблема теперь в том, что если у меня есть этот SSL (порт 443), перенаправленный на мою виртуальную машину Windows, на виртуальной машине Windows я могу получить доступ к Google только через https, я не могу открыть любую другую веб-страницу, которая использует https. http просто отлично работает. При удалении строк для пересылки 443 в сценарии перехвата Интернет в виртуальной машине снова работает для страниц https. Что мне здесь не хватает?
Я сам решил.
У моего интерфейса eth0 только внешний IP-адрес, поэтому я добавил "-d [External IP] / 32", и теперь он работает нормально.
Линия выглядит так
/sbin/iptables -t nat -A PREROUTING -p tcp -d [external IP]/32 --dport $HOST_PORT -j DNAT --to $GUEST_IP:$GUEST_PORT