Configuring DHCP Service - Playing OpenStack in 5 Minutes a Day (89)

In the previous chapter, we saw that instance can obtain IP from Neutron's DHCP service during the startup process. This section will discuss its internal implementation mechanism in detail.

The component of Neutron that provides DHCP services is the DHCP agent. The DHCP agent runs on the network node and implements the DHCP function through dnsmasq by default.

Configure DHCP agent

The configuration file for the DHCP agent is located at /etc/neutron/dhcp_agent.ini.

dhcp_driver
implements DHCP using dnsmasq.

interface_driver
uses linux bridge to connect to the DHCP namespace interface.

When a network is created and DHCP is enabled on the subnet, the DHCP agent on the network node will start a dnsmasq process to provide DHCP services for the network.

dnsmasq is an open source software that provides DHCP and DNS services. There is a one-to-one relationship between dnsmasq and network. A dnsmasq process can provide services for all subnets with DHCP enabled in the same netowrk.

Back to our experimental environment, we created flat_net before, and enabled DHCP on the subnet. Execute ps to view the dnsmasq process, as shown in the following figure:

The DHCP agent will create a directory /opt/stack/data/neutron/dhcp/ for each network, which is used to store the dnsmasq configuration file of the network.

The important startup parameters of dnsmasq are discussed below:

--dhcp-hostsfile
The file that stores the DHCP host information, the host here is actually the instance in our case. dnsmasq obtains the correspondence between the host's IP and MAC from this file. Each host corresponds to an entry, and the information comes from the Neutron database.

For flat_net, the hostsfile is /opt/stack/data/neutron/dhcp/f153b42f-c3a1-4b6c-8865-c09b5b2aa274/host, which records the interface information of DHCP, cirros-vm1 and cirros-vm2.

--interface
specifies the interface that provides the DHCP service. dnsmasq will listen for instance DHCP requests on this interface.

For flat_net, the interface is ns-19a0ed3d-fe. Maybe you still remember that the DHCP interface we saw before is called tap19a0ed3d-fe (as shown in the figure below), not ns-19a0ed3d-fe.

image584.png

From the name, there should be some connection between ns-19a0ed3d-fe and tap19a0ed3d-fe, but what is that?

To answer this question, you need to understand a concept: Linux Network Namespace , which we will discuss in detail in the next section.

 

blob.png

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324541090&siteId=291194637