4
votes

I created 2 ubuntu virtual machines on azure and I can log into one machine from the other using "ssh azureuser@xyz.cloudapp.net" but pinging one virtual machine from another gives no response. same thing with curl.

ping xyz.cloudapp.net 
curl xyz.cloudapp.net 

Modifying the /etc/hosts file with the internal ip addresses of the virtual machines doesn't work either.

3

3 Answers

5
votes

ICMP (Ping) is blocked in Azure so by design this will fail. You can get this to work depending on how you are setting up your network and what you are trying to ping. See https://social.msdn.microsoft.com/Forums/en-US/0669112c-a6dd-4290-bcde-9ce7b9d60d80/how-do-i-enable-pinging-a-vm for more details:

•Ping external address from Azure VM - does not work as Azure does not permit outbound ICMP

•Ping Azure VM from external address - does not work as Azure does not permit inbound ICMP

•Ping between Azure VMs using internal IP (DIP) - works, but guest OS firewall must be configured to allow it as by default ICMP is blocked by the guest.

•Ping between Azure VM and on-premise through Azure Connect (point-to-point IPSec VPN tunnel) or Virtual Network Gateway (site-to-site IPSec VPN tunnel) - works, but guest OS firewall must be configured to allow it as by default ICMP is blocked by the guest.

To allow ICMP on a Windows VM, from an elevated command prompt, run:

netsh advfirewall firewall add rule name="ICMPv6" dir=in action=allow enable=yes protocol=icmpv6 netsh advfirewall firewall add rule name="ICMPV4" dir=in action=allow enable=yes protocol=icmpv4

1
votes

You can try hping3 ping host on port number,

sudo apt-get install hping3
root@compare:~# sudo hping3 -S -p 80 google.com
HPING google.com (eth0 216.58.196.174): S set, 40 headers + 0 data bytes
len=44 ip=216.58.196.174 ttl=53 id=20026 sport=80 flags=SA seq=0 win=42900 rtt=32.8 ms
len=44 ip=216.58.196.174 ttl=53 id=34969 sport=80 flags=SA seq=1 win=42900 rtt=36.6 ms
len=44 ip=216.58.196.174 ttl=53 id=14912 sport=80 flags=SA seq=2 win=42900 rtt=32.6 ms
len=44 ip=216.58.196.174 ttl=53 id=60826 sport=80 flags=SA seq=3 win=42900 rtt=32.5 ms
len=44 ip=216.58.196.174 ttl=53 id=5138 sport=80 flags=SA seq=4 win=42900 rtt=32.3 ms
^C
--- google.com hping statistic ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 32.3/33.4/36.6 ms
root@compare:~#
0
votes

UPDATE 2021: As of 2021, you can ping to your azure virtual machine by opening the ICMP port.
Just go to Azure Portal > Virtual Machines > Select your Virtual Machine > Networking > Add inbound port rule > Select ICMP under Protocol (customize as per your needs) > Add