> For the complete documentation index, see [llms.txt](https://kawsing.gitbook.io/opensystem/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kawsing.gitbook.io/opensystem/andoid-shou-ji/untitled-4/shell-script/zhao-chu-ni-de-dhcp-server.md).

# 找出你的DHCP Server

方法一：

從你的log紀錄，可以獲得區域網路內提供你  DHCP 服務的機器位址

```
sudo grep -r "DHCPOFFER" /var/log/* | grep "$(export LC_ALL=C; date +'%b %d')" | tail -1
```

方法二：tcpdump + dhclient

```
sudo tcpdump -i wlp4s0  -pvn port 67 and port 68
dhclient 你的網路介面
```

![](/files/-LwaXyWn4eeTThKMncqs)

方法三：使用 nmap (推薦，可掃出區網的DHCP Server)

```
sudo nmap --script broadcast-dhcp-discover -e wlp4s0

Starting Nmap 7.60 ( https://nmap.org ) at 2019-12-21 11:51 CST
Pre-scan script results:
| broadcast-dhcp-discover: 
|   Response 1 of 1: 
|     IP Offered: 192.168.43.102
|     DHCP Message Type: DHCPOFFER
|     Server Identifier: 192.168.43.1
|     IP Address Lease Time: 1d00h00m00s
|     Renewal Time Value: 12h00m00s
|     Rebinding Time Value: 21h00m00s
|     Subnet Mask: 255.255.255.0
|     Router: 192.168.43.1
|_    Domain Name Server: 192.168.43.1, 192.168.43.1
WARNING: No targets were specified, so 0 hosts scanned.
Nmap done: 0 IP addresses (0 hosts up) scanned in 0.47 seconds

```
