Home > Mobile >  finding hostname using IP address in shell script linux
finding hostname using IP address in shell script linux

Time:01-27

I'd appreciate it if anyone could help me with this issue, I need a shell script that is capable of finding IP addresses using the hostname. can anyone help me?

CodePudding user response:

What have you tried out so far? Though for starters there are a couple of tools you can use to achieve this. If using linux, nmblookup -A <hostname.com> would produce something like this Looking up status of <IP address> Let me know exactly what you want to achieve.

okello@okello-XPS-13-7390:~$ nmblookup -A google.com
Looking up status of 172.217.170.206

CodePudding user response:

To find an IP address from a URL, you can use nslookup. If you want only the IP address itself, you can pipe it to grep and use a lookbehind regex to filter for the part after the text "Address: ".

nslookup google.com | grep -Po "(?<=^Address: ).*"
  •  Tags:  
  • Related