大网数据广告活动
服务器运维问答

Azure RM NSG Port Forwarding Not Working

· 52CE 我爱测

I have a Debian 6.x box that I needed to move to Azure. Before moving it up, I did make sure that SSH is listening on any port, so is Apache. My NSG has all of the right ports opened (22, 443 for now). I uploaded the VHD, then us…

问题原文

原帖链接 · suprphrk · CC BY-SA 3.0

I have a Debian 6.x box that I needed to move to Azure. Before moving it up, I did make sure that SSH is listening on any port, so is Apache. My NSG has all of the right ports opened (22, 443 for now). I uploaded the VHD, then used the following PowerShell commands to create the VM based off of the VHD:

$vnet = get-AzureRmVirtualNetwork -Name $VnetName -ResourceGroupName $VnetRG
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "$SubnetName" -VirtualNetwork $vnet
$pip = Get-AzureRmPublicIpAddress -Name "$pipName" -ResourceGroupName $resourceGroupName
$NSG = Get-AzureRmNetworkSecurityGroup -Name "$NSGName" -ResourceGroupName $resourceGroupName
$nic = New-AzureRmNetworkInterface -ResourceGroupName $resourceGroupName -Name $nicName -Subnet $subnet -Location $location -PrivateIpAddress $newVMIP -DnsServer $dnsServer1,$dnsServer2 -PublicIpAddress $pip -NetworkSecurityGroup $NSG
$newVM = New-AzureRmVMConfig -VMName $newVMName -VMSize $newVMSize | Add-AzureRmVMNetworkInterface -Id $nic.Id | Set-AzureRmVMOSDisk -VhdUri $vhdPath -Name $diskname -CreateOption attach -Linux -Caching ReadWrite
New-AzureRMVM -ResourceGroupName $resourceGroupName -Location $location -VM $newVM -DisableBginfoExtension

I can see that the machine is running as I can view the auto-logged-in desktop in boot diagnostics. However, when I try to SSH or when I try to access the web site over 22 and 443, it's not returning any response. Telnet times out and it's acting like the port isn't forwarding at all.

I understand that because it's Debian 6.x, waagent isn't supported. But I shouldn't need waagent for port forwarding, should I? From what I understand about networking and from what I see in MSDN forums, "The port forwarding should be invisible to your end machine. As the public hits the public port and your VM receives on the internal port." (https : //social.msdn.microsoft.com/Forums/en-US/bd93f5cb-a674-4b9c-aa5a-9f6e7b364f2c/port-forwarding-still-broken?forum=WAVirtualMachinesforWindows)

Did I mis-key or miss something in my PowerShell script? Any ideas?

I have tried deleting and re-creating the VM and I've tried re-uploading the VHD file. I did have to convert it from VHDX to VHD, but that shouldn't matter since it's actually booting up and I see the screen in boot diags.

The NSG I used does work for any other newly created machine via portal or PowerShell, just not this uploaded machine, which makes me think I've flubbed something in the script. Everything does show that it's open for port 22 and 443 though. Here's a screen grab of the Effective Security Rules blade: rules screenshot

The iptables on the local machine are empty as shown in this screen grab.

What's weird is that I can't SSH to it from another machine on the same virtual network either. I tried going through the steps at https : //docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-linux-debian-create-upload-vhd?toc=%2Fazure%2Fvirtual-machines%2Flinux%2Ftoc.json, but since it's Debian 6, the waagent won't install. But again, I shouldn't need an agent on the machine for port forwarding to work. No other virtualization technology requires an agent for NAT to work.

Edit - this was suggested as a duplicate of StackOverflow. I originally asked the question there, but everyone suggested I post my question here. So I did that, marking the StackOverflow answer as the answer.

已采纳解答

原帖链接 · suprphrk · CC BY-SA 3.0

Debian 6 won't work in Azure. You have to use "Legacy Network Adapter" in Hyper-V, and that doesn't work in Azure. Or, you'd have to recompile the kernel to support the Hyper-V drivers for the NIC, and that's not recommended either. Looks like I have to try to migrate the data to a new server.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-09)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。