以下是将上述内容排版为Markdown格式：

### 安装相关工具及命令
```bash
apt install iw
iw list | grep AP

sudo apt-get update
sudo apt-get install hostapd dnsmasq iptables-persistent
```

### 配置 `/etc/dnsmasq.conf`
```bash
sudo nano /etc/dnsmasq.conf
```
添加如下内容：
```
interface=wlan0
bind-interfaces
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=192.168.100.2,192.168.100.254,255.255.255.0,24h
```

### 配置 `/etc/hostapd/hostapd.conf`
```bash
sudo nano /etc/hostapd/hostapd.conf
```
添加如下内容：
```
interface=wlan0
driver=nl80211
ssid=YourHotspotName
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=YourPassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
```

### 配置 `/etc/sysctl.conf`
```bash
sudo nano /etc/sysctl.conf
```
找到并取消注释（删除行首的 `#`）以下行：
```
net.ipv4.ip_forward=1
```
然后执行：
```bash
sudo sysctl -p
```

### 设置 iptables 规则
```bash
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o wlan0 -j ACCEPT

sudo netfilter-persistent save
```

### 配置网络接口
```bash
sudo ifconfig wlan0 192.168.100.1 netmask 255.255.255.0
```

### 启动服务
```bash
sudo systemctl unmask hostapd
sudo systemctl enable --now hostapd dnsmasq
```