DHCP 服务器:使用 3G 调制解调器、Fedora(DHCP)和 Wi-Fi 路由器创建私有网络

DHCP 服务器:使用 3G 调制解调器、Fedora(DHCP)和 Wi-Fi 路由器创建私有网络

我正在配置我的家庭网络。我有一个 USB 3G 调制解调器和一个 Wi-Fi 路由器,该路由器有一个用于 DSL/有线连接的以太网端口。

我计划让我的笔记本电脑通过 USB 调制解调器连接到 3G,并将流量路由到笔记本电脑的以太网端口,这样当我将笔记本电脑连接到路由器时,它可以用作 Wi-Fi 路由器的有线互联网连接。

我仍然停留在配置 DHCP 上。

这是的内容/etc/dhcp/dhcpd.conf

[引用]

# Sample /etc/dhcpd.conf
# (add your comments here)
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.1.255;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.1, 192.168.1.2;
option domain-name "mydomain.org";

subnet 192.168.1.0 netmask 255.255.255.0 {
   range 192.168.1.10 192.168.1.100;
   range 192.168.1.150 192.168.1.200;
}

路线:目前我做的是:

# route add -host 255.255.255.255 dev eth0

然后我执行:

# dhcpd eth0

我收到的错误是:

[root@spark dhcp]# sudo dhcpd eth0
Internet Systems Consortium DHCP Server 4.2.1-P1
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit [url]https://www.isc.org/software/dhcp/[/url]
Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Wrote 0 leases to leases file.

No subnet declaration for eth0 (no IPv4 addresses).
** Ignoring requests on eth0.  If this is not what
   you want, please write a subnet declaration
   in your dhcpd.conf file for the network segment
   to which interface eth0 is attached. **


Not configured to listen on any interfaces!

This version of ISC DHCP is based on the release available
on ftp.isc.org.  Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.

Please report for this software via the Red Hat Bugzilla site:
    [url]http://bugzilla.redhat.com[/url]

exiting.
[root@spark dhcp]#

ifconfig输出

[root@spark dhcp]# ifconfig
em2       Link encap:Ethernet  HWaddr 98:4B:E1:EF:7B:36
          inet6 addr: fe80::9a4b:e1ff:feef:7b36/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10588 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9506 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1902468 (1.8 MiB)  TX bytes:962611 (940.0 KiB)
          Interrupt:45 Base address:0xe000

eth0      Link encap:Ethernet  HWaddr CC:52:AF:54:19:BD
          inet6 addr: fe80::ce52:afff:fe54:19bd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:109 errors:0 dropped:0 overruns:0 frame:192354
          TX packets:33 errors:20 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:15181 (14.8 KiB)  TX bytes:6798 (6.6 KiB)
          Interrupt:16

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:16436  Metric:1
          RX packets:109435 errors:0 dropped:0 overruns:0 frame:0
          TX packets:109435 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:8260005 (7.8 MiB)  TX bytes:8260005 (7.8 MiB)

ppp0      Link encap:Point-to-Point Protocol
          inet addr:115.184.XXX.XXX  P-t-P:220.224.XXX.XXX  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:31 errors:0 dropped:0 overruns:0 frame:0
          TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3
          RX bytes:7768 (7.5 KiB)  TX bytes:5950 (5.8 KiB)

[root@spark dhcp]#

它说我缺少子网声明,但事实并非如此。我收到此错误的原因可能是什么?

答案1

“它说我缺少子网声明,但事实并非如此。”

是的,当 dhcpd 告诉你一些事情时,请听从它。

具体来说,您已为 指定了子网声明192.168.1.0/24,但 DHCP 服务器无法为网络请求提供服务,因为您的计算机未直接连接到它。eth0在该网络中提供一个地址,然后观察 dhcpd 是否正常运行!

答案2

啊哈,我明白了。我忘了为 eth0 接口分配 IP 地址:

# ifconfig eth0 192.168.1.100 

真是个陷阱 :|

相关内容