0

note: I will call the server running isc-dhcp-server "DHCP-SERVER", and computer wired to my switch "DHCP-Clients"

Hi, I am currently setting-up a network, and i am unable to share internet over the DHCP clients. I am also using isc-dhcp-server My DHCP-SERVER can ping google.com for instance, login using SSH my dhcp-clients. My DHCP-Clients can ping the DHCP-Server, and nothing else. When running ping google.com, here's the output

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

Here, you can find a drawing of my setup


DHCP-SERVER

Interfaces:

  1. WLAN: wlp2s0, Connected to my wifi router, can interact with the world (eg. ping google.com working)
  2. Ethernet: enx0050b62184c1, connected to my switch, can interact with wired clients to the switch
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 config file

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;
   }

}

What i've tried so far

I tried to use the following command on my DHCP-Server iptables -t nat -A POSTROUTING -s 10.0.2.0/28 -j MASQUERADE

I also enabled net.ipv4.ip_forward. sysctl -w net.ipv4.ip_forward=1

In my /etc/network/interfaces file, i also tried to replace 192.168.1.1 to my given IP, 192.168.1.99.


But nothing works. Any idea why?


Answer from MeMow: I changed "option domain-name-servers none;" to my local DNS IP (the one provided by my ISP). Now, when pinging a website i have this issue:

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

2 Answers2

0

Assuming the client has internet access and can actually ping an external IP address, i'd guess it's a DNS issue.

I don't see any DNS served by your DHCP config?

there should be

option domain-name-servers DNS_IP;

instead of none

MeMow
  • 292
  • 1
  • 7
0

As per your ping output you still have an issue with routing. Most probably it wasn't abled properly. It should be enabled via

echo 1 > /proc/sys/net/ipv4/ip_forward

The below line should be added to /etc/sysctl.conf in order not to loose the retting after reboot.

net.ipv4.ip_forward = 1

Also your iptables NAT rule doesn't contain destination. You need to specify dst or output interface.

iptables -t nat -A POSTROUTING -s 10.0.2.0/28 -d 0/0 -j MASQUERADE

or

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Make sure the rules are not lost after reboot. Normally they should be saved to the files with the following commands. Debian/Ubuntu:

iptables-save > /etc/iptables/rules.v4

RHEL/CentOS:

iptables-save > /etc/sysconfig/iptables
Hardoman
  • 255
  • 1
  • 7