AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-608388

user3503112's questions

Martin Hope
user3503112
Asked: 2020-12-30 01:58:41 +0800 CST

DHCP 服务器 - 无法与客户端共享 Internet

  • 0

注意:我将运行 isc-dhcp-server 的服务器称为“DHCP-SERVER”,并将连接到我的交换机的计算机称为“DHCP-Clients”

嗨,我目前正在建立一个网络,但我无法通过 DHCP 客户端共享互联网。我也在使用isc-dhcp-server 例如,我的 DHCP-SERVER 可以 ping google.com,使用 SSH 我的 dhcp-clients 登录。我的 DHCP 客户端可以 ping DHCP 服务器,除此之外别无其他。运行 ping google.com 时,输出如下

user@client1:~ $ ping google.com
ping: google.com: Temporary failure in name resolution

在这里,您可以找到 我的设置图


DHCP服务器

接口:

  1. WLAN:wlp2s0,连接到我的wifi路由器,可以与世界交互(例如ping google.com工作)
  2. 以太网:enx0050b62184c1,连接到我的交换机,可以与交换机的有线客户端交互
isri@shuttle:~$ cat /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

auto enx0050b62184c1
iface enx0050b62184c1 inet static
  address 10.0.2.1
  #netmask 255.255.255.240
  gateway 192.168.1.1
user@dhcp-server:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever

2: enx0050b62184c1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:50:b6:21:84:c1 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.1/8 brd 10.255.255.255 scope global enx0050b62184c1
       valid_lft forever preferred_lft forever
    inet6 fe80::250:b6ff:fe21:84c1/64 scope link
       valid_lft forever preferred_lft forever

3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether b0:c0:90:92:c4:6b brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.99/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp2s0
       valid_lft 86329sec preferred_lft 86329sec
    inet6 fe80::b2c0:90ff:fe92:c46b/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

/etc/dhcp/dhcpd.conf

user@dhcp-server:~$ cat /etc/default/isc-dhcp-server
# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
#DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPDv4_PID=/var/run/dhcpd.pid
#DHCPDv6_PID=/var/run/dhcpd6.pid

# Additional options to start dhcpd with.
#       Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#       Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACESv4="enx0050b62184c1"
#INTERFACESv6=""

dhcpd 配置文件

user@dhcp-server:~$ cat /etc/dhcp/dhcpd.conf
# dhcpd.conf
option domain-name "my-network";
# option domain-name-servers none;
# option domain-name-servers 192.168.1.1;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
subnet 10.0.2.0 netmask 255.255.255.240 {
   range 10.0.2.2 10.0.2.14;
   option routers 10.0.2.1;
   host client1 {
      hardware ethernet b8:27:eb:d3:83:02;
      fixed-address     10.0.2.6;
   }

   host client2 {
      hardware ethernet b8:27:eb:1e:8f:9d;
      fixed-address     10.0.2.5;
   }

   host client3 {
      hardware ethernet b8:27:eb:bd:fc:16;
      fixed-address     10.0.2.4;
   }

}

到目前为止我尝试过的

我尝试在我的 DHCP 服务器上使用以下命令 iptables -t nat -A POSTROUTING -s 10.0.2.0/28 -j MASQUERADE

我还启用了 net.ipv4.ip_forward。 sysctl -w net.ipv4.ip_forward=1

在我的 /etc/network/interfaces 文件中,我还尝试将 192.168.1.1 替换为我的给定 IP 192.168.1.99。


但没有任何效果。知道为什么吗?


MeMow 的回答:我更改了“option domain-name-servers none;” 到我的本地 DNS IP(由我的 ISP 提供的 IP)。现在,在 ping 一个网站时,我遇到了这个问题:

user@client1:~ $ ping google.com
PING google.com (142.250.74.238) 56(84) bytes of data.
From 10.0.2.1 (10.0.2.1) icmp_seq=1 Destination Host Unreachable
From 10.0.2.1 (10.0.2.1) icmp_seq=2 Destination Host Unreachable
From 10.0.2.1 (10.0.2.1) icmp_seq=3 Destination Host Unreachable
debian dhcp isc-dhcp
  • 2 个回答
  • 265 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve