以下信息显示了我的 /etc/network/interfaces、/etc/dnsmasq.conf、iptables-save 输出和 /proc/net/ipv4/ip_foward 文件的当前内容。从 ifconfig -a 信息(最后显示)中,您可以看到 ETH0 适配器正在获取 169.254.62.167 地址,而不是 172.24.1.x 网络上的地址。当我从笔记本电脑连接到 WLAN0 上的 AP(HOSTAPD)时,我获得了 172.24.1.x 地址,并且可以 ssh 进入机器(172.24.1.1),我可以 ssh 到 192.168.1.x 网络上的机器。
ETH0 适配器与该网络上的其他 4 台机器一起连接到交换机。我希望 172.24.1.1 主机上的 ETH0 适配器从 DNSMASQ 池获取地址,并且我希望其他四台机器也从 172.24.1.1 主机获取地址。
如果需要,我愿意静态解决所有问题,但是,如果可能的话,我愿意使用 DHCP。
关于我需要做什么才能让 eth0 网络从 172.24.1.1 主机获取 DHCP 地址,以及如果可能的话让同一网络(连接到交换机)上的其他机器也请求 DHCP 地址,有什么想法吗?
/etc/network/interfaces
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet static
address 172.24.1.1
netmask 255.255.255.0
network 172.24.1.0
broadcast 172.24.1.255
allow-hotplug wlan1
iface wlan1 inet dhcp
wireless-essid 2WIRE4038
wireless-mode managed
/etc/dnsmasq.conf
interface=wlan0
listen-address=172.24.1.1
bind-interfaces
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=172.24.1.50,172.24.1.151,12h
dhcp-range=interface:eth0,172.24.1.152,172.24.1.202,12h
#iptables-save
*filter
:INPUT ACCEPT [1060:194768]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [665:83883]
-A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o wlan1 -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [192:39054]
:INPUT ACCEPT [81:17177]
:OUTPUT ACCEPT [129:12221]
:POSTROUTING ACCEPT [59:6396]
-A POSTROUTING -o wlan1 -j MASQUERADE
COMMIT
#proc/sys/net/ipv4/ip_forward
1
**#ifconfig -a
eth0 Link encap:Ethernet HWaddr b8:27:eb:fe:9a:19
inet addr:169.254.62.167 Bcast:169.254.255.255 Mask:255.255.0.0
inet6 addr: fe80::be96:d2a7:f81a:6edb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:92 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1968 (1.9 KiB) TX bytes:20881 (20.3 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:416 errors:0 dropped:0 overruns:0 frame:0
TX packets:416 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:32922 (32.1 KiB) TX bytes:32922 (32.1 KiB)
wlan0 Link encap:Ethernet HWaddr 74:da:38:6f:5b:c6
inet addr:172.24.1.1 Bcast:172.24.1.255 Mask:255.255.255.0
inet6 addr: fe80::f0cb:6dd6:a312:eba0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2226 errors:0 dropped:0 overruns:0 frame:0
TX packets:911 errors:0 dropped:10 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:203720 (198.9 KiB) TX bytes:208596 (203.7 KiB)
wlan1 Link encap:Ethernet HWaddr b8:27:eb:ab:cf:4c
inet addr:192.168.1.210 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::eee2:dff6:a22a:5852/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:518 errors:0 dropped:0 overruns:0 frame:0
TX packets:213 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:133141 (130.0 KiB) TX bytes:29096 (28.4 KiB)**