VMWare Fusion虚拟机内部如何访问VPN ?



我在MacOS BigSur中有VPN连接,但我无法在VMWare Fusion V12.1.2下运行的Linux虚拟机中访问它。

该问题已在V12.2.0中修复VMWare Fusion 12.2.0发布说明

解决方案是手动创建VPN隧道并将其链接到虚拟机,因为涉及多个命令,IP地址可以更改。我创建了以下脚本来执行所需的命令。

#!/bin/bash
function ask_yes_or_no() {
read -p "$1 ([y]es or [N]o): "
case $(echo $REPLY | tr '[A-Z]' '[a-z]') in
y|yes) echo "yes" ;;
*)     echo "no" ;;
esac
}
currNatRules=$(sudo pfctl -a com.apple.internet-sharing/shared_v4 -s nat 2>/dev/null)
if test -z "$currNatRules" 
then
echo -e "nThere are currently no NAT rules loadedn"
exit 0
fi
utunCheck=$(echo $currNatRules | grep utun)
if test -n "$utunCheck"
then
echo -e "nIt looks like the VPN tunnel utun2 has already been created"
echo -e "n$currNatRulesn"
if [[ "no" == $(ask_yes_or_no "Do you want to continue?") ]]
then
echo -e "nExitingn"
exit 0
fi
fi

natCIDR=$(echo $currNatRules | grep en | grep nat | cut -d  -f 6)
if test -z "$natCIDR" 
then
echo -e "nCannot extract the NAT CIDR from:"
echo -e "n$currNatRulesn"
exit 0
fi
interface=$(route get 10/8 | grep interface | cut -d  -f 4)
echo -e "nNAT CIDR=$natCIDR Interface=$interfacen"
newRule="nat on ${interface} inet from ${natCIDR} to any -> (${interface}) extfilter ei"
echo -e "nAdding new rule: $newRulen"
configFile="fixnat_rules.conf"
[[ -d $configFile ]] && rm $configFile
echo "$currNatRules" > $configFile
echo "$newRule" >> $configFile
sudo pfctl -a com.apple.internet-sharing/shared_v4 -N -f  ${configFile} 2>/dev/null
echo -e "nConfig update appliedn"
sudo pfctl -a com.apple.internet-sharing/shared_v4 -s nat 2>/dev/null
echo -e "n"
exit 0

最新更新