On a Linux system, you can use the dhclient command to identify any Dynamic Host Configuration Protocol (DHCP) servers that are available on the local area network (LAN). First, you need to determine a relevant network interface on the system over which an IP address might be acquired via DHCP. You can do so using the ip command. If the
-f inet
option is given to the command, it will show only IPv4
addresses.# ip -f inet address 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever 2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 inet 192.168.0.35/24 brd 192.168.0.255 scope global dynamic enp4s0 valid_lft 156092sec preferred_lft 156092sec 3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever
Alteratively, you can use the
ifconfig command with the -a
option to show all network
interfaces and any assigned IP addresses for them. I.e.,
ifconfig -a
.
In the example above from a CentOS 7 system, I can see that an IP address is
assigned to the enp4s0
network interface and that is the interface
I will use for the DHCP query to locate any DHCP servers on the network, which
may be legitimate or rogue DNS servers.
To have the dhclient command search for DHCP servers, I'll use the
-d
and -nw
options.
[ More Info ]