neutron dhcp

neutron dhcp 采用dnsmasq服务来实现。和传统的 dhcp 一样, dhcp请求也分为4步

The client sends a discover (“I’m a client at MAC address 08:00:27:b9:88:74, I need an IP address”)
The server sends an offer (“OK 08:00:27:b9:88:74, I’m offering IP address 10.10.0.112”)
The client sends a request (“Server 10.10.0.131, I would like to have IP 10.10.0.112”)
The server sends an acknowledgement (“OK 08:00:27:b9:88:74, IP 10.10.0.112 is yours”)

dnsmasq把log写入系统log,正常的log如下

Aug 24 14:52:37 controller100 dnsmasq[6299]: read /var/lib/neutron/dhcp/b5a8fe96-77c7-443c-8a2b-a862fd016301/addn_hosts - 3 addresses
Aug 24 14:52:37 controller100 dnsmasq-dhcp[6299]: read /var/lib/neutron/dhcp/b5a8fe96-77c7-443c-8a2b-a862fd016301/host
Aug 24 14:52:37 controller100 dnsmasq-dhcp[6299]: read /var/lib/neutron/dhcp/b5a8fe96-77c7-443c-8a2b-a862fd016301/opts
Aug 24 14:52:48 controller100 dnsmasq-dhcp[6299]: DHCPDISCOVER(ns-b8d4df6d-14) fa:16:3e:11:85:5d
Aug 24 14:52:48 controller100 dnsmasq-dhcp[6299]: DHCPOFFER(ns-b8d4df6d-14) 192.168.1.4 fa:16:3e:11:85:5d
Aug 24 14:52:48 controller100 dnsmasq-dhcp[6299]: DHCPREQUEST(ns-b8d4df6d-14) 192.168.1.4 fa:16:3e:11:85:5d
Aug 24 14:52:48 controller100 dnsmasq-dhcp[6299]: DHCPACK(ns-b8d4df6d-14) 192.168.1.4 fa:16:3e:11:85:5d host-192-168-1-4

后面的4步是DHCP请的过程。 第一步

 read /var/lib/neutron/dhcp/b5a8fe96-77c7-443c-8a2b-a862fd016301/addn_hosts - 3 addresses

是查看已经分配的ip(包括这次即将分配的ip)

/var/lib/neutron/dhcp/b5a8fe96-77c7-443c-8a2b-a862fd016301/host

该文件记录了ip 和 mac的映射

/var/lib/neutron/dhcp/b5a8fe96-77c7-443c-8a2b-a862fd016301/opts

该文件记录了dhcp服务器的地址等

我们做一个实验,禁用compute的网卡的混杂模式。这样vm发出的package,在回复的时候就无法到达vm,因为host机器的网卡会扔掉该package。 这时的dhcp log如下:

Aug 24 14:56:34 controller100 dnsmasq[6299]: read /var/lib/neutron/dhcp/b5a8fe96-77c7-443c-8a2b-a862fd016301/addn_hosts - 4 addresses
Aug 24 14:56:34 controller100 dnsmasq-dhcp[6299]: read /var/lib/neutron/dhcp/b5a8fe96-77c7-443c-8a2b-a862fd016301/host
Aug 24 14:56:34 controller100 dnsmasq-dhcp[6299]: read /var/lib/neutron/dhcp/b5a8fe96-77c7-443c-8a2b-a862fd016301/opts
Aug 24 14:56:46 controller100 dnsmasq-dhcp[6299]: DHCPDISCOVER(ns-b8d4df6d-14) fa:16:3e:d9:b7:42
Aug 24 14:56:46 controller100 dnsmasq-dhcp[6299]: DHCPOFFER(ns-b8d4df6d-14) 192.168.1.5 fa:16:3e:d9:b7:42
Aug 24 14:57:46 controller100 dnsmasq-dhcp[6299]: DHCPDISCOVER(ns-b8d4df6d-14) fa:16:3e:d9:b7:42
Aug 24 14:57:46 controller100 dnsmasq-dhcp[6299]: DHCPOFFER(ns-b8d4df6d-14) 192.168.1.5 fa:16:3e:d9:b7:42
Aug 24 14:58:46 controller100 dnsmasq-dhcp[6299]: DHCPDISCOVER(ns-b8d4df6d-14) fa:16:3e:d9:b7:42
Aug 24 14:58:46 controller100 dnsmasq-dhcp[6299]: DHCPOFFER(ns-b8d4df6d-14) 192.168.1.5 fa:16:3e:d9:b7:42

可以看到只有dhcp discover和dhcp offer。但是offer无法继续到达vm,所以request 就发不出来,自然就没有ack

posted on 2016-08-24 15:19  kramer  阅读(336)  评论(0编辑  收藏  举报

导航