0

My system is Linux. I use udhcpd tool to build a dhcp server. I want to know what method(static or dhcp) is used for connected device on my linux server How can I do? do have any cmd can reach this goal?

Thank you!!

Niu Ar
  • 21
  • 1
  • If it's in your lease list, its used DHCP. If not -then it's Static… But this is a Basic Business Admin knowledge…?! And if you set up a forced IP, with a MAC, and it's reachable by this. It worked as expected. I don't see really here a business relationship or environmental question. – djdomi Sep 04 '22 at 14:47

1 Answers1

1

You can use the ip tool. This tells your whether the IP is dynamic or not. Below is an example output which shows the keyword dynamic. This means there was some dynamic process (e.g. DHCP) to fetch the IP.

$ ip address
...
4: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether aa:aa:aa:aa:aa:aa brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.184/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp3s0
       valid_lft 65779sec preferred_lft 65779sec

In addition you can list all your interfaces/IPs which have dynamic (or permanent) IP addresses with e.g. ip address show dynamic. See also https://manpages.debian.org/unstable/iproute2/ip-address.8.en.html