Как узнать свой dhcp сервер
Перейти к содержимому

Как узнать свой dhcp сервер

  • автор:

Как найти IP-адрес DHCP-сервера через командную строку в Windows?

Linux имеет простые команды для поиска IP-адреса DHCP-сервера через командную строку.

есть ли что-нибудь для Windows?

3 ответов

DHCP-сервер, используемый для получения адреса, включается в вывод ipconfig /all .

enter image description here

Если ваш компьютер имеет статический IP, то ipconfig /all не будет показывать DHCP-сервер в вашей сети. В этом случае можно использовать следующую командную строку для ее отображения.

Find DHCP Server IP Address on Linux Command Line

Find DHCP Server IP Address on Linux Command Line

I recently received an email from a reader asking «How do I find the IP address of my DHCP server»? My initial reaction was «Hmmm, good question». That lead me to investigate the fastest way to find your DHCP server IP address from the Linux command line.

What is a DHCP Server?

A DHCP Server is a system on a network that manages dynamic configuration of client systems on the network. DHCP (Dynamic Host Configuration Protocol) is a standard network protocol used on almost all IP networks. It allows for dynamic configuration of network parameters on systems connected to the network. Before DHCP an administrator would have to configure each system individually. For more information on DHCP, see the Resource and Links section below.

How to Find Your DHCP Server IP Address

There is no simple command to show the IP address of the DHCP server on the network. However, there are places it is recorded, if you know where to look. Here are a few ways you can find the IP address of a DHCP server on your network.

NOTE: You will need root or sudo access to run all of these commands.

Find DHCP Server IP Using grep to Find Log Entries

The first method I thought of was to check the logs for the DHCPOFFER. The DHCPOFFER packet would come from the DHCP server and should be written to your logs. Here we use grep with some options (-I to ignore binary files, -R for recursive) to find the log file entry that contains our DHCP server IP address.

CentOS 7 example:

Fedora 30 example:

Ubuntu 19.04 example:

NOTE: Notice that every distribution stores it in a different log file? That is why we recursively search the whole /var/log/ directory.

Using Journalctl and grep

You can do the same as above using journalctl.

To learn more about using journalctl read «Viewing logs with journalctl».

Find DHCP Server IP Address using Leases File

The dhclient utility stores your lease information in leases file. These lease files are kept in different places for different distros, software loads, and different versions.

NOTE: Replace [interface] with the name of your network interface (i.e. eth0, eno1, etc..)

Now use grep to find the DHCP server.

If you are using NetworkManager, you can find the lease file location by looking at the running processes (ps aux).

Now that you know where the leases file is, you can get the DHCP server IP address from that file.

We can string both of these operations together to simplify the process.

Find DHCP Server IP Using dhclient Utility

Another way would be to use the dhclient utility with some options. This also requires root or elevated privileges. The drawback of this is that the dhclient will go through the whole DHCP D.O.R.A. process. This also means that your DHCP server, network and client system need to be configured correctly. This is not much help if you are troubleshooting DHCP issues.

Conclusion

There you have it, a few different methods to find the IP address of your DHCP server. I am sure there are other ways, as with anything in Linux. If you know of another way please leave it in the comments and I will update the article.

How can I find my DHCP server?

On my LAN there are multiple DHCP servers running, and all of them are on the same range.

Now I use a machine which has a dynamic IP address from a DHCP server. I have to know from which server it comes.

Aaron's user avatar

5 Answers 5

To find out the DHCP server that’s giving you the IP, just press Ctrl + Alt + T on your keyboard to open Terminal. When it opens, run the command(s) below:

Oбрывки в скоросшивателе

Клочки бумаги, на которых обычно ведутся записи, имеют обыкновение теряться, если их вовремя не подшить. Мысли на тему линукса, а может и не только его, — чтоб не забыть.

2016-05-12

Поиск левого DHCP для самых маленьких

Маленькая детективная история, которая началась с того, что у клиентов начали появляться трудности с доступом к сетевым ресурсам. Выяснилось что они получают IP-адреса с какого-от левого источника (да, это можно предотвратить, но что не сделано — то не сделано).

    на компе, получившим левый адрес, делаем
    ipconfig /all

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

Ваш адрес email не будет опубликован. Обязательные поля помечены *