https://wiki.archlinux.org/api.php?action=feedcontributions&user=Davejagoda&feedformat=atomArchWiki - User contributions [en]2024-03-29T14:20:21ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Dhcpd&diff=267668Dhcpd2013-07-23T13:59:20Z<p>Davejagoda: pointed out this may not work any more.</p>
<hr />
<div>[[Category:Networking]]<br />
dhcpd is the [http://www.isc.org/software/dhcp/documentation Internet Systems Consortium] DHCP Server. It is useful for instance on a machine acting as a router on a LAN.<br />
<br />
== Installation ==<br />
[[pacman|Install]] the {{pkg|dhcp}} package, available in the [[official repositories]].<br />
<br />
== Configuration ==<br />
Assign an static IPv4 address to the interface you want to use (usually {{ic|eth0}}). The first 3 bytes of this address cannot be exactly the same as those of another interface.<br />
{{bc|<br />
# ip link set up dev eth0<br />
# ip addr add 139.96.30.100/24 dev eth0 # arbitrary address<br />
}}<br />
To have your static ip assigned at boot, you can use [[netcfg]].<br />
<br />
The default {{ic|dhcpd.conf}} contains many uncommented examples, so relocate it<br />
{{bc|<br />
# mv /etc/dhcpd.conf /etc/dhcpd.conf.example<br />
}}<br />
Edit the configuration file to contain:<br />
{{hc|/etc/dhcpd.conf|<br />
# Using the google's dns in the example.<br />
# Change it to 139.96.30.100 if you have a dns server installed<br />
option domain-name-servers 8.8.8.8;<br />
option subnet-mask 255.255.255.0;<br />
option routers 139.96.30.100;<br />
subnet 139.96.30.0 netmask 255.255.255.0 {<br />
range 139.96.30.150 139.96.30.250;<br />
}<br />
}}<br />
<br />
Start, and optionally, enable for autostart on boot, the {{ic|dhcpd4.service}} daemon. <br />
<br />
Read [[Daemons]] for more information.<br />
<br />
Now, any computer you connect over ethernet will be assigned an IPv4 address (from {{ic|139.96.30.150}} to {{ic|139.96.30.250}} in this example).<br />
<br />
== Tips and Tricks ==<br />
=== Listening on only one interface ===<br />
If your computer is already part of one or several networks, it could be a problem if your computer starts giving ip addresses to machines from the other networks.<br />
<br />
In order to force the DHCP server to listen only on one of the network interfaces, you need to specify it in the dhcpd command line. <br />
<br />
(This appears not to work as of ArchLinux 2013-07-01 - see talk page for details)<br />
<br />
This is done by editing the configuration file:<br />
{{hc|/etc/conf.d/dhcp|<nowiki><br />
# Assuming the device of your lan is eth1<br />
DHCP4_ARGS="-q eth1"<br />
</nowiki>}}<br />
Another step is to tell the routing table on which interface to listen to for the 255.255.255.255 broadcasts:<br />
{{bc|<br />
# ip route add 255.255.255.255 dev eth1<br />
}}<br />
Now, the clients on {{ic|eth1}} will be managed by your DHCP server without having any impact on any client / server on any other ntework interface.<br />
<br />
== Notes ==<br />
You will see configuration files, etc. related to {{ic|dhcpcd}}. That one is the DHCP '''client''' executable and has nothing to do with {{ic|dhcpd}}.<br />
<br />
==See also==<br />
*[[Dhcpcd]]</div>Davejagodahttps://wiki.archlinux.org/index.php?title=Talk:Dhcpd&diff=267665Talk:Dhcpd2013-07-23T13:56:10Z<p>Davejagoda: Created page with "The part about editing this file to have dhcpd listen on a particular interface appears outdated: /etc/conf.d/dhcp I was able to get it to listen on a specific interface by ..."</p>
<hr />
<div>The part about editing this file to have dhcpd listen on a particular interface appears outdated:<br />
<br />
/etc/conf.d/dhcp<br />
<br />
I was able to get it to listen on a specific interface by editing this file:<br />
<br />
/etc/systemd/system/multi-user.target.wants/dhcpd4.service<br />
<br />
This works, but I am not sure that this is the best place to make the edit. Can anyone suggest a better place, or confirm this is the best place?</div>Davejagoda