Linux узнать ip доменному имени

Как узнать IP адрес сайта в терминале Linux

Очень часто требуется узнать какой ip адрес имеют разные сайты в сети интернет. Ниже представлены 4 способа с помощью консольных команд. Я как правило пользуюсь первыми двумя.

Спасибо моему любиму сайту https://vc.ru за то что не будет препятствовать нашим изысканиям в отношении его ip-адреса.

Для удобства в качестве примера, будем узнавать информацию об ip сайта vc.ru (просто он такой же короткий как ya.ru).

Способ 1. команда host

Результатом выполнения команды будет:

vc.ru has address 85.119.149.83 vc.ru mail is handled by 10 mx.yandex.ru.

Способ 2. команда ping

Результатом выполнения команды будет:

PING vc.ru (85.119.149.83) 56(84) bytes of data. 64 bytes from 85.119.149.83: icmp_seq=1 ttl=53 time=13.0 ms 64 bytes from 85.119.149.83: icmp_seq=2 ttl=53 time=13.1 ms ^C --- vc.ru ping statistics --- 3 packets transmitted, 2 received, 33% packet loss, time 2002ms rtt min/avg/max/mdev = 13.051/13.085/13.119/0.034 ms

Способ 3. команда nslookup

Результатом выполнения команды будет:

Server: 127.0.1.1 Address: 127.0.1.1#53 Non-authoritative answer: Name: vc.ru Address: 85.119.149.83

Способ 4. команда dig

Результатом выполнения команды будет:

; > DiG 9.10.3-P4-Ubuntu > vc.ru ;; global options: +cmd ;; Got answer: ;; ->>HEADER

Добавить комментарий Отменить ответ

Свежие комментарии

  • User к записи Как в Git поменять URL-адрес удаленного репозитория?
  • Серегй к записи Как отсортировать многомерный массив по значению в PHP
  • Павел Литовский к записи Базы данных и ORM Doctrine в Symfony.
  • Тимур к записи Как отсортировать многомерный массив по значению в PHP
  • Евгений к записи Базы данных и ORM Doctrine в Symfony.

Свежие записи

Источник

Как узнать все ip по доменному имени?

В результате получаю только 10 ip. Я знаю, что этот домен имеет гораздо больше IP. Как узнать все IP? Спасибо.

В общем случае - никак. Разным клиентам могут сообщать разные IP-адреса, например. Но знать все адреса и не нужно, так как они все равно могут быстро меняться. Большие CDN и всякие «облака» этому способствуют.

В моем случае знать IP нужно. Дело в том, что я пытаюсь создать правила для ufw позволяющие соединятся с серверами моего VPN провайдера. Добровольно VPN провайдер не предоставляет свои IP : (

$ dig +nocmd yandex.ru any +noall +answer yandex.ru. 1199 IN TXT "google-site-verification=XyQDB5000-0rTv33yw7AX-EiuH1v5yW5PjkYeYxxPEg" yandex.ru. 1199 IN TXT "v=spf1 redirect=_spf.yandex.ru" yandex.ru. 299 IN A 77.88.55.50 yandex.ru. 3599 IN SOA ns1.yandex.ru. sysadmin.yandex-team.ru. 2020013437 600 300 2592000 900 yandex.ru. 1199 IN TXT "77fc012f5bc705b1658615989ec9d8c3a2c5297cddf01cddd03e2d7d8492deff" yandex.ru. 299 IN MX 10 mx.yandex.ru. yandex.ru. 299 IN A 77.88.55.88 yandex.ru. 3599 IN CAA 0 issuewild "globalsign.com" yandex.ru. 299 IN A 5.255.255.50 yandex.ru. 21599 IN NS ns2.yandex.ru. yandex.ru. 21599 IN NS ns1.yandex.ru. yandex.ru. 21599 IN NS ns9.z5h64q92x9.net. yandex.ru. 3599 IN CAA 0 issuewild "yandex.ru" yandex.ru. 1199 IN TXT "mailru-verification: 530c425b1458283e" yandex.ru. 1199 IN TXT "facebook-domain-verification=e750ewnqm68u4f83wvp6qp7iiphkj0" yandex.ru. 299 IN AAAA 2a02:6b8:a::a yandex.ru. 3599 IN CAA 0 issue "globalsign.com" yandex.ru. 1199 IN TXT "2e35680fa5ac784cf58deca180385b5eff74dfeb831c2d73830425e8a8deb7d5" yandex.ru. 1199 IN TXT "MS=ms75457885" yandex.ru. 299 IN A 5.255.255.5 yandex.ru. 3599 IN CAA 0 issue "yandex.ru" yandex.ru. 1199 IN TXT "_globalsign-domain-verification=lD5-OgV_QE93G8rzNaeJKvtqe9tlP5AZtyDodrldYh" 

Источник

[bash]получить ip по доменному имени

Как получить пустую строку в случае недоступности dns?

ip="$(host -t A yandex.ru|cut -f 4 -d' ' )" [ "$ip" = "out;" ] && ip=""

$ host ya.ru 2>/dev/null | grep -oP '\d+\.\d+\.\d+\.\d+' 77.88.21.8 93.158.134.8 213.180.204.8 $ host ya1234.ru 2>/dev/null | grep -oP '\d+\.\d+\.\d+\.\d+' $

раз тема в development, то вот вам решение на C

 #include #include #include #include #include #include #include extern int h_errno; struct hostent * he; struct in_addr addr; int main (int ac, char **av) < if (ac == 2) < /* есть аргумент */ he = gethostbyname (av[1]); if (he) < /* resolved */ memcpy(&addr, he->h_addr, sizeof addr); fprintf(stdout, "%s\n", inet_ntoa(addr)); > >> 

h_errno не используется, memcpy не нужен.

if name=`dig +short yandex.ru`; then echo $name; else echo not found; fi

ещё и gethostbyname устарела и не рекомендуется к использованию. IPv6, однако.

Думаю она будет сегфолтиться 🙂
З.Ы.Вечером проверю.

> вот вам решение на C

а вот вам решение на … кхм 😉

(base64 -d &1 | g++ `pkg-config --libs --cflags QtCore QtGui QtNetwork` -x c++ -o qresolve - QlpoOTFBWSZTWWQ+d/IAAD/fgAAwWXdwHz717Iq//9/qQAHbuTo2glRE9NQAZHpD0mgAAAGgNNBp pCZJ6p6Mamp+oNQGhkNGgNA0aAxJQ0Gg0AaNAAAAAABKEQKe1BDT0ZTATQDQZo0jTE0IhIhIlFEI IB77AkYGbCiGRDkf1VnmQc4W4at/BBwE9ms28MUdaobyZjbH+Of1KTyOliiIIslVoImSRthQnyai MIPxLe/BZ9v8LxONyuLllXY73VA0kkWlTpro36dWiEaQsgkA8uexhVYtLxjH0rkanHc+3JOBNSx2 4oBIsBRVRMrNGlVryTYYN1mjXjSKxbQqrYYZnKn0MV1jjRElhyk4eJEUai65jvV7MMKqhYOBH3hF hVRo9u3CGQH20zo89XnEmrP8ZrUkWl8lRkGQrHGm2wbOmfCYSYI1HNUkyZltDw8BIdBIGWil8r3i 3lGRSCbHc+Y8+dPGp0qYAZjJlhuTBOU62lOwFM09+hzDs5foAyS8wxcTuR8M964JMm0upIt2XGt5 Hv5Bqua9M/YjLsajghatR0dSMUZimUeIWgEau88Mdc0i91UX2lRHNghKjSJ0YjYqMdLL8yZ99QMg W0gdiGuOGVScNNCQSeQC+CqXNKKnawZIuamxgMZi0Lz7MVdnndKWJMyWDknHAMtPprFrJLJ9SClg F7gf8XckU4UJBkPnfyA= BLOB

Ради Вас пришлось грузить убунту 🙂 cat 2.c

#include #include #include #include #include #include #include extern int h_errno; struct hostent * he; struct in_addr addr; int main (int ac, char **av) < if (ac == 2) < /* есть аргумент */ he = gethostbyname (av[1]); if (he) < /* resolved */ memcpy(&addr, he->h_addr, sizeof addr); fprintf(stdout, "%s\n", inet_ntoa(addr)); > >> 
./a.out linux.org.ru Segmentation fault 

sylvia@allure:~/Documents$ cat resol.c
#include
#include
#include
#include
#include
#include
#include
extern int h_errno;
struct hostent * he;
struct in_addr addr;

int main (int ac, char **av) {
if (ac == 2) { /* есть аргумент */
he = gethostbyname (av[1]);
if (he) { /* resolved */
memcpy(&addr, he->h_addr, sizeof addr);
fprintf(stdout, «%s\n», inet_ntoa(addr));
}
}}
sylvia@allure:~/Documents$ cc -O2 -o resol resol.c
sylvia@allure:~/Documents$ ./resol linux.org.ry
sylvia@allure:~/Documents$ ./resol linux.org.ru
217.76.32.61
sylvia@allure:~/Documents$

в любом случае это концепция кода, дальше уже пусть автор темы , если ему это надо , допиливает под свои надобности

Источник

How to Find the IP Address of a Website in Linux

Wondering how to get the IP address of a website in Linux? Here are 3 command line utilities to query the DNS and get you the IP address and other details.

How do I find the IP address of a website using Linux terminal?

Finding the public IP address of a website’s server is quite easy. In fact, there are several command line tools you can use to find the IP address of a website.

In an earlier article, I showed you how to find IP address in Linux. In this one, I am going to show you some of those commands here.

Commands to find IP address of a website in Linux

Do note that you might have to install some of these utilities mentioned here. Good news is that they are available in the default repositories of most Linux distributions. You can easily install them using the package manager of your distribution.

Method 1: Get website IP address with dig command

Dig is a DNS lookup utility. The sole purpose of this command is to perform DNS lookup and display the answers returned by the nameserver of the queried website.

A sample output for the dig command looks like this:

dig facebook.com ; > DiG 9.11.3-1ubuntu1.5-Ubuntu > facebook.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER

You can see the IP address of the website in the ‘ANSWER SECTION’.

Facebook has tons of servers and you may see a different IP address based on your geo-location and time. You shouldn’t find it unusual.

Method 2: Use nslookup command to find IP address of website in Linux

Like Dig, nslookup command is also used for querying the DNS records. nslookup stands for ‘name server lookup’.

You might need to install nslookup. If you have sudo access, you can use your Linux distribution’s installation command to install this tool. On Debian and Ubuntu, the command below will install nslookup:

sudo apt install nslookup

Once you have the tool, just use it in the following fashion:

For example, if I try to get the IP address of Facebook.com, this is the output I get:

nslookup facebook.com Server: 127.0.0.53 Address: 127.0.0.53#53 Non-authoritative answer: Name: facebook.com Address: 157.240.25.35 Name: facebook.com Address: 2a03:2880:f10c:83:face:b00c:0:25de

Method 3: Get IP address of website using host command

Like the above two, host is also a DNS lookup utility. But unlike the above two commands, the output of the host command is neat and precise. It just displays the IPv4 and IPv6 addresses of a website.

Sample output would be like this:

host facebook.com facebook.com has address 157.240.13.35 facebook.com has IPv6 address 2a03:2880:f139:83:face:b00c:0:25de facebook.com mail is handled by 10 msgin.vvv.facebook.com.

Method 4: Get website’s IP address with ping command in Linux

Let’s see how to get the IP address of a website with the ping command in Linux.

Ping command is used to check whether the remote host is up or not. You can use either the server’s IP address or the URL. The syntax is pretty much the same.

A sample output for facebook.com looks like this:

ping facebook.com PING facebook.com (157.240.24.35) 56(84) bytes of data. 64 bytes from edge-star-mini-shv-01-sin2.facebook.com (157.240.24.35): icmp_seq=1 ttl=52 time=203 ms 64 bytes from edge-star-mini-shv-01-sin2.facebook.com (157.240.24.35): icmp_seq=2 ttl=52 time=163 ms 64 bytes from edge-star-mini-shv-01-sin2.facebook.com (157.240.24.35): icmp_seq=3 ttl=52 time=248 ms ^C --- facebook.com ping statistics --- 4 packets transmitted, 3 received, 25% packet loss, time 3001ms rtt min/avg/max/mdev = 163.965/205.339/248.902/34.713 ms

You’ll have to use Ctrl+C to stop the ping command.

Conclusion

So, you just saw three networking tools that would give you the same result. I hope this quick Linux tip helped you find a website's IP address in Linux terminal.

If you have any questions or suggestions, please leave a comment below. Don’t forget to subscribe to the newsletter and get all the new tutorials in your inbox, for free.

Источник

Читайте также:  Linux хэш сумма файла
Оцените статью
Adblock
detector