DBDIR/dhcpd.leases

Fbsdnew

Member

Reaction score: 4
Messages: 87

I've installed isc-dhcp44-server and client and have read the manual pages for dhcpd.leases. The instructions say to look in man page of dhcpd.leases if you don't know what to do, which is that when dhcpd is invoked it cannot find var/db/dhcpd.leases. In the man page it says to create "touch DBDIR/dhcpd.leases as an empty file. I'm stuck with this error. Please will someone help me and point me in the right direction?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,279
Messages: 33,825

It's not supposed to go there.
Code:
dice@maelcum:~ % ll /var/db/dhcpd/dhcpd.leases
-rw-r--r--  1 dhcpd  dhcpd  173182 Aug  3 17:42 /var/db/dhcpd/dhcpd.leases
dice@maelcum:~ % pkg info -x dhcp
isc-dhcp44-client-4.4.2
isc-dhcp44-server-4.4.2
 
OP
F

Fbsdnew

Member

Reaction score: 4
Messages: 87

Woops, I missed the -cf option in the manpage for alternate config file. Anyway, I wrote a blank /var/db/dhcpd.leases and now I'm at the next step, where it wants a subnet declaration for every interface. It does not show how to write a subnet declaration for my interfaces in the man page. For the network segment to which interface re0 is attached. Also how do I find out what the network segment is to which that interface is attached?
 
Last edited:

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,279
Messages: 33,825

Anyway, I wrote a blank /var/db/dhcpd.leases and now I'm at the next step
Wrong location. It should be /var/db/dhcpd/dhcpd.leases. The rc(8) script already handles this correctly. The reason it's in /var/db/dhcpd/ is because the script allows you to spawn multiple instances, each from its own directory.

Also how do I find out what the network segment is to which that interface is attached?
It's your network, so I hope you know where each subnet is.
 
OP
F

Fbsdnew

Member

Reaction score: 4
Messages: 87

I don't know what a subnet is. Or that my interfaces had one even.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,279
Messages: 33,825

Subnetting and network segments in general are routing 101. You should be familiar with TCP/IP and basic routing. If not then you need to study it. Or else you're going to have a hard time configuring services like this. You can't configure them properly if you don't know what you're doing.

What interfaces does your machine have? And how are they configured? What do you intend to do with the DHCP service?
 
OP
F

Fbsdnew

Member

Reaction score: 4
Messages: 87

The interface is re0 configured through DHCP from installation. I just know DHCP is networking and want to get certified along with being familiar with everything else about FreeBSD, and I want to learn networking either way so, I figured I should turn my box into a DHCP server and see how it works and then go from there. I'm currently reading Michael Lucas books for the tcp/ip stuff but haven't ran into the network segment and subnet terms enough to understand it.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,279
Messages: 33,825

The interface is re0 configured through DHCP from installation.
Then you can't run a DHCP service on that interface. It must be on a static address. And running another DHCP server on the same network is going to cause problems. Both DHCP servers are going to respond to requests, and it's going to be a game of chance which one will be applied. Rule number one, NEVER run more than one DHCP service on your network (unless they're specifically configured to be each other's backup).

I figured I should turn my box into a DHCP server and see how it works and then go from there.
I would suggest just using tcpdump(1) and just look at it from a client's perspective. You already have a functioning DHCP server on your network (most likely your internet modem/router). Keep reading the book and just use tcpdump(1) to look at the actual packets on your network.

If you really want to muck around, set up a virtual network with two FreeBSD machines using Virtualbox for example. That will give you enough room to play with without having to change anything on your (working) home network.
 

mjollnir

Daemon

Reaction score: 700
Messages: 1,154

I don't know what a subnet is. Or that my interfaces had one even.
In today's terminology, a network address is useless on it's own. It must be accompanied by a (sub-) network mask. The modern notation is to note the number of network bits after a slash, e.g. 192.168.1.1/24 for IPV4.
 
OP
F

Fbsdnew

Member

Reaction score: 4
Messages: 87

Then you can't run a DHCP service on that interface. It must be on a static address. And running another DHCP server on the same network is going to cause problems. Both DHCP servers are going to respond to requests, and it's going to be a game of chance which one will be applied. Rule number one, NEVER run more than one DHCP service on your network (unless they're specifically configured to be each other's backup).


I would suggest just using tcpdump(1) and just look at it from a client's perspective. You already have a functioning DHCP server on your network (most likely your internet modem/router). Keep reading the book and just use tcpdump(1) to look at the actual packets on your network.

If you really want to muck around, set up a virtual network with two FreeBSD machines using Virtualbox for example. That will give you enough room to play with without having to change anything on your (working) home network.
What about the interface "vm-services" I keep getting "rc.conf: vm-services not found" I have VM services enabled in rc.conf.
 
Last edited:

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,279
Messages: 33,825

What about the interface "vm-services" I keep getting "rc.conf: vm-services not found" I have VM services enabled in rc.conf.
What do you mean? What exactly did you enable?

If you want to play with bhyve instead of Virtualbox that's fine too, I can recommend using sysutils/vm-bhyve for easy management.
 
OP
F

Fbsdnew

Member

Reaction score: 4
Messages: 87

There's an article about how to setup networking in Bhyve with jails and a virtual switch called "Arranging Your Virtual Network on FreeBSD". I omitted the steps that are not needed. The steps are...
1.pkg install vm-bhyve
2.service vm enable
3.sysrc vm_dir=zfs:zroot/vms
4.zfs create zroot/vms
5.vm switch create -a 10.1.1.1/24 services
6.create vnetjail
7.ifconfig -g epair
8.pkg install dnsmasq
9.service dnsmasq enable
10.service dnsmasq start
11.vm iso (...)
12.vm create guest
13.vm add -d network -s services guest
14.vm console guest
no where does it ask for this entry in rc.conf but I keep getting the error message "ifconfig_vm-services="DHCP" not found"
 
OP
F

Fbsdnew

Member

Reaction score: 4
Messages: 87

What do you mean? What exactly did you enable?

If you want to play with bhyve instead of Virtualbox that's fine too, I can recommend using sysutils/vm-bhyve for easy management.
I'll try both but I haven't found any other way than what I've mentioned to get networking in Bhyve. Do you know of any other ways? If not ill just stick with the virtual box cause I'm pretty sure its easier.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,279
Messages: 33,825

That vm-services is a switch created by vm-bhyve, it uses a bridge(4) interface for that. Bridges don't need an IP address, so you can remove that. There's some nice info on the vm-bhyve wiki: https://github.com/churchers/vm-bhyve/wiki

I have two "virtual switches":
Code:
# vm switch list
NAME     TYPE      IFACE       ADDRESS  PRIVATE  MTU   VLAN  PORTS
servers  standard  vm-servers  -        no       9000  11    lagg0
public   standard  vm-public   -        no       9000  10    lagg0
Those correspond with two bridge(4) interfaces, named vm-servers and vm-public:
Code:
# ifconfig vm-public
vm-public: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 9000
        ether 0e:67:86:9b:42:3e
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto stp-rstp maxaddr 2000 timeout 1200
        root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
        member: tap11 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 22 priority 128 path cost 2000000
        member: tap10 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 21 priority 128 path cost 2000000
        member: tap9 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 20 priority 128 path cost 2000000
        member: tap8 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 19 priority 128 path cost 2000000
        member: tap6 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 17 priority 128 path cost 2000000
        member: tap5 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 16 priority 128 path cost 2000000
        member: tap4 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 15 priority 128 path cost 2000000
        member: tap3 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 14 priority 128 path cost 2000000
        member: lagg0.10 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 10 priority 128 path cost 55
        groups: bridge vm-switch viid-4c918@
        nd6 options=1<PERFORMNUD>
Code:
# ifconfig vm-servers
vm-servers: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 9000
        ether 4e:86:1c:5a:88:a3
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto stp-rstp maxaddr 2000 timeout 1200
        root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
        member: tap7 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 18 priority 128 path cost 2000000
        member: tap2 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 13 priority 128 path cost 2000000
        member: tap1 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 12 priority 128 path cost 2000000
        member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 11 priority 128 path cost 2000000
        member: lagg0.11 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                ifmaxaddr 0 port 8 priority 128 path cost 55
        groups: bridge vm-switch viid-d5539@
        nd6 options=1<PERFORMNUD>
 

wolffnx

Well-Known Member

Reaction score: 103
Messages: 445

I've installed isc-dhcp44-server and client and have read the manual pages for dhcpd.leases. The instructions say to look in man page of dhcpd.leases if you don't know what to do, which is that when dhcpd is invoked it cannot find var/db/dhcpd.leases. In the man page it says to create "touch DBDIR/dhcpd.leases as an empty file. I'm stuck with this error. Please will someone help me and point me in the right direction?
if you still want to do this on you FreeBSD main install, please post the output of ifconfig
 
OP
F

Fbsdnew

Member

Reaction score: 4
Messages: 87

if you still want to do this on you FreeBSD main install, please post the output of ifconfig
Code:
[root@machine17 ~]# ifconfig
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
    ether 00:30:67:b6:b4:d9
    inet6 fe80::230:67ff:feb6:b4d9%re0 prefixlen 64 scopeid 0x1
    media: Ethernet autoselect (none)
    status: no carrier
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet6 ::1 prefixlen 128
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
    inet 127.0.0.1 netmask 0xff000000
    groups: lo
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet 172.31.255.17 netmask 0xffffffff
    inet6 fe80::1%lo1 prefixlen 64 scopeid 0x3
    groups: lo
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
re0.5: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=80003<RXCSUM,TXCSUM,LINKSTATE>
    ether 00:30:67:b6:b4:d9
    inet 192.168.20.20 netmask 0xffffff00 broadcast 192.168.20.255
    inet6 fe80::230:67ff:feb6:b4d9%re0.5 prefixlen 64 scopeid 0x4
    groups: vlan
    vlan: 5 vlanpcp: 0 parent interface: re0
    media: Ethernet autoselect (none)
    status: no carrier
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
wlan0: flags=b843<UP,BROADCAST,RUNNING,SIMPLEX,LINK0,LINK1,MULTICAST> metric 0 mtu 1500
    ether a4:2b:8c:e3:69:8d
    inet6 fe80::a62b:8cff:fee3:698d%wlan0 prefixlen 64 scopeid 0x5
    inet 192.168.0.40 netmask 0xffffff00 broadcast 192.168.0.255
    groups: wlan
    ssid CenturyLink4339 channel 6 (2437 MHz 11g ht/20) bssid 5c:e2:8c:d3:e1:0c
    regdomain FCC country US authmode WPA2/802.11i privacy ON
    deftxkey UNDEF TKIP 3:128-bit txpower 30 bmiss 7 scanvalid 60
    protmode CTS ht20 ampdulimit 64k ampdudensity 4 shortgi -stbc -ldpc
    wme roaming MANUAL
    media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
    status: associated
    nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
pflog0: flags=141<UP,RUNNING,PROMISC> metric 0 mtu 33160
    groups: pflog
vm-services: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether a2:f4:46:4b:a4:c0
    inet 10.1.1.1 netmask 0xffffff00 broadcast 10.1.1.255
    id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
    maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
    root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
    groups: bridge vm-switch viid-10cd3@
    nd6 options=1<PERFORMNUD>
 

wolffnx

Well-Known Member

Reaction score: 103
Messages: 445

Code:
[root@machine17 ~]# ifconfig
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
    ether 00:30:67:b6:b4:d9
    inet6 fe80::230:67ff:feb6:b4d9%re0 prefixlen 64 scopeid 0x1
    media: Ethernet autoselect (none)
    status: no carrier
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet6 ::1 prefixlen 128
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
    inet 127.0.0.1 netmask 0xff000000
    groups: lo
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
    inet 172.31.255.17 netmask 0xffffffff
    inet6 fe80::1%lo1 prefixlen 64 scopeid 0x3
    groups: lo
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
re0.5: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    options=80003<RXCSUM,TXCSUM,LINKSTATE>
    ether 00:30:67:b6:b4:d9
    inet 192.168.20.20 netmask 0xffffff00 broadcast 192.168.20.255
    inet6 fe80::230:67ff:feb6:b4d9%re0.5 prefixlen 64 scopeid 0x4
    groups: vlan
    vlan: 5 vlanpcp: 0 parent interface: re0
    media: Ethernet autoselect (none)
    status: no carrier
    nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
wlan0: flags=b843<UP,BROADCAST,RUNNING,SIMPLEX,LINK0,LINK1,MULTICAST> metric 0 mtu 1500
    ether a4:2b:8c:e3:69:8d
    inet6 fe80::a62b:8cff:fee3:698d%wlan0 prefixlen 64 scopeid 0x5
    inet 192.168.0.40 netmask 0xffffff00 broadcast 192.168.0.255
    groups: wlan
    ssid CenturyLink4339 channel 6 (2437 MHz 11g ht/20) bssid 5c:e2:8c:d3:e1:0c
    regdomain FCC country US authmode WPA2/802.11i privacy ON
    deftxkey UNDEF TKIP 3:128-bit txpower 30 bmiss 7 scanvalid 60
    protmode CTS ht20 ampdulimit 64k ampdudensity 4 shortgi -stbc -ldpc
    wme roaming MANUAL
    media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
    status: associated
    nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
pflog0: flags=141<UP,RUNNING,PROMISC> metric 0 mtu 33160
    groups: pflog
vm-services: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
    ether a2:f4:46:4b:a4:c0
    inet 10.1.1.1 netmask 0xffffff00 broadcast 10.1.1.255
    id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
    maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
    root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
    groups: bridge vm-switch viid-10cd3@
    nd6 options=1<PERFORMNUD>
and what interface want to use to put te dhcp daemon to listen?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,279
Messages: 33,825

Don't put it on the "virtual switch". Build two FreeBSD VMs. Connect both to that virtual switch, no need to connect that switch to anything else. You want to isolate it so you can play around without interference. Set up one of the VMs as the DHCP server and the other as a DHCP client.
 

wolffnx

Well-Known Member

Reaction score: 103
Messages: 445

vm-services
first, take the advice from SirDice , and next I pass to you the steps for make a functional dhcp server

/usr/local/etc/dhcpd.conf

Code:
# option definitions common to all supported networks...
option domain-name "your-domain-name";

default-lease-time 600;
max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative; #only if the only dhcp server on your network

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;


# DHCP server to understand the network topology.

#assume a /24 network mask
subnet 10.1.1.0 netmask 255.255.255.0 {
range  10.1.1.5 10.1.1.253; #this is the from and end ip's that you deliver
option routers  10.1.1.1; #your default gateway
option domain-name-servers  8.8.8.8; #the dns
default-lease-time 21600;
}


#address reservation, make shure that not overlap with the <range> rule above
#host machineA  {
#hardware ethernet xx.xx.xx.xx.xx.xx;
#fixed-address 10.1.1.x;
#}
/etc/rc.conf

Code:
dhcpd_enable="YES"                                        # dhcpd enabled?
dhcpd_ifaces="vm-services"                              # ethernet interface(s)



This is a vey basic configuration,for your purposes(testing and learn) you dont need
a firewall in the server machine (only for testing and in a closed lan)

for stop/start/restart the service I allway point to
/usr/local/etc/rc.d/isc-dhcpd [restart] [stop] [start]

reboot and good luck
 

mjollnir

Daemon

Reaction score: 700
Messages: 1,154

Or maybe one more indirection: service isc-dhcpd enable (or sysrc dhcpd_enable=yes) and service isc-dhcpd start/stop/restart/reload/rcvar/...
 

wolffnx

Well-Known Member

Reaction score: 103
Messages: 445

service isc-dhcpd start/stop/restart/reload/rcvar/...
This one I dont know it, I allways control it from /usr/local/etc/rc.d/isc-dhcpd
this service isc-dhcpd is more way better and short
 
Top