You are not logged in.

#1 2022-11-20 08:53:48

tesla135
Member
Registered: 2013-06-27
Posts: 76

[SOLVED]Basic dhcp file configuration

Hi, I'm interested to create a small dhcp server, I'm using a virtualbox to do this some tests with it.

I have an arch virtualbox with two interfaces, one is  from 192.168.1.0/24 network (enp0s3) and one is from 192.168.2.0/24 with static ip 192.168.2.1.

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: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:2a:af:bb brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.77/24 brd 192.168.1.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet 192.168.1.109/24 brd 192.168.1.255 scope global secondary dynamic noprefixroute enp0s3
       valid_lft 172304sec preferred_lft 150704sec
    inet6 fe80::a00:27ff:fe2a:afbb/64 scope link 
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:50:0f:2b brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.1/24 brd 192.168.2.255 scope global noprefixroute enp0s8
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe50:f2b/64 scope link 
       valid_lft forever preferred_lft forever

And I want a SIMPLE dhcp server on enp0s8(with a pool  range of ips 192.168.2.2-192.168.2.80) , so I tried various configurations, here is my last
/etc/dhcpcd.conf

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
#hostname

# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# vendorclassid is set to blank to avoid sending the default of
# dhcpcd-<version>:<os>:<machine>:<platform>
vendorclassid

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Request a hostname from the network
option host_name

# Most distributions have NTP support.
#option ntp_servers

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
noipv4ll
 
interface enp0s8
static ip_address=192.168.2.1/24
static broadcast_address=192.168.2.255
static routers=192.168.2.1
static domain_name_server=192.168.2.1

I do not know how to add pool ranges!!

And here is my last dhcpcd status:

● dhcpcd.service - dhcpcd on all interfaces
     Loaded: loaded (/usr/lib/systemd/system/dhcpcd.service; enabled; preset: disabled)
     Active: active (running) since Mon 2022-11-14 23:34:20 UTC; 18s ago
    Process: 3300 ExecStart=/usr/bin/dhcpcd -q -b (code=exited, status=0/SUCCESS)
   Main PID: 3302 (dhcpcd)
      Tasks: 6 (limit: 1144)
     Memory: 1.6M
        CPU: 99ms
     CGroup: /system.slice/dhcpcd.service
             ├─3302 "dhcpcd: [manager] [ip4] [ip6]"
             ├─3303 "dhcpcd: [privileged proxy]"
             ├─3304 "dhcpcd: [network proxy]"
             ├─3305 "dhcpcd: [control proxy]"
             ├─3310 "dhcpcd: [BPF ARP] enp0s8 192.168.2.1"
             └─3312 "dhcpcd: [BPF ARP] enp0s3 192.168.1.109"

Nov 14 23:34:22 myhostname dhcpcd[3303]: enp0s3: offered 192.168.1.109 from 192.168.1.1
Nov 14 23:34:22 myhostname dhcpcd[3303]: enp0s3: probing address 192.168.1.109/24
Nov 14 23:34:25 myhostname dhcpcd[3303]: enp0s8: using static address 192.168.2.1/24
Nov 14 23:34:25 myhostname dhcpcd[3303]: enp0s8: adding route to 192.168.2.0/24
Nov 14 23:34:25 myhostname dhcpcd[3303]: enp0s8: adding default route via 192.168.2.1
Nov 14 23:34:27 myhostname dhcpcd[3303]: enp0s3: leased 192.168.1.109 for 172800 seconds
Nov 14 23:34:27 myhostname dhcpcd[3303]: enp0s3: adding route to 192.168.1.0/24
Nov 14 23:34:27 myhostname dhcpcd[3303]: enp0s3: adding default route via 192.168.1.1
Nov 14 23:34:32 myhostname dhcpcd[3303]: enp0s3: no IPv6 Routers available
Nov 14 23:34:32 myhostname dhcpcd[3303]: enp0s8: no IPv6 Routers available

Basically  it does not give ip to lans machines

Last edited by tesla135 (2022-11-20 10:13:54)

Offline

#2 2022-11-20 09:17:41

Grigorios
Member
Registered: 2021-01-10
Posts: 27

Re: [SOLVED]Basic dhcp file configuration

You are trying to set up a DHCP server, but you are using the dhcpcd (DHCP Client daemon) but what you want to use it an actual DHCP server like DHCPD.


Greetings

Grigorios

Last edited by Grigorios (2022-11-20 09:19:08)

Offline

Board footer

Powered by FluxBB