Page 1 of 1
get current ip and hostname using ping -4 -a ""
Posted: 21 Nov 2014 12:53
by carlos
Hello. I found some curious thing.
When you use ping -a and specify empty string: ""
It use the hostname of your computer.
Using this:
you get your computer name and your ip.:
Code: Select all
C:\Users\areaweb2>ping -4 -a ""
Haciendo ping a PC01 [192.168.10.201] con 32 bytes de datos:
Respuesta desde 192.168.10.201: bytes=32 tiempo<1m TTL=128
Re: get current ip and hostname using ping -4 -a ""
Posted: 21 Nov 2014 13:06
by Compo
Same here in Windows Technical Preview [Version 6.4.9879]
Re: get current ip and hostname using ping -4 -a ""
Posted: 21 Nov 2014 14:44
by Squashman
This works as well.
ping ""
Re: get current ip and hostname using ping -4 -a ""
Posted: 21 Nov 2014 17:19
by foxidrive
ping -4 "" works as carlos says and gives me an IPV4 address and
ping "" works too but gives me an IPV6 address
It works in XP Pro (no IPV6 there) and Windows 8.1
That's really cool - a neat shortcut!
Edit: I should make it clear that I get the computer name and IP address without the -a switch.
Re: get current ip and hostname using ping -4 -a ""
Posted: 21 Nov 2014 20:32
by Squashman
Windows 7 gives me IP4 with just the quotes. It also gives host name.
Re: get current ip and hostname using ping -4 -a ""
Posted: 21 Nov 2014 21:37
by foxidrive
Squashman wrote:Windows 7 gives me IP4 with just the quotes. It also gives host name.
Yes, it depends on the modem being used for the internet connection UIAM.
When I got an IPV6 capable modem then Windows started showing me IPV6 addesses, even though IPV6 was disabled in the modem by default.
Re: get current ip and hostname using ping -4 -a ""
Posted: 21 Nov 2014 23:02
by bars143
it does not need findstr to extract ip adress of hostname.