openstack私有云布署实践【18 修改实例DHCP服务的DNS IP】
某天,由于Linux服务器默认没有DNS缓存功能,每次服务器每访问一个http域名链接时,都会触发一次DNS域名解析查询,降低了调用API接口的时延,所以我司后续启用的内网的dnsmasq DNS服务功能,需要将实例的DNS IP进行修改
登录一台controller
source admin-openrc.sh
neutron subnet-list
+--------------------------------------+---------------------------------------------------+------------------+------------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+---------------------------------------------------+------------------+------------------------------------------------------+
| 333b430f-bffe-47ed-9c1c-14a33618f569 | HA subnet tenant 18649c1da2594d31988fd26baf15252b | 169.254.192.0/18 | {"start": "169.254.192.1", "end": "169.254.255.254"} |
| 358321c0-6cbc-4ed7-a9e3-d8e7c3a6cf3a | 17216150 | 172.16.150.0/24 | {"start": "172.16.150.11", "end": "172.16.150.253"} |
| 291efb02-af77-429f-bc9e-95b714a804da | 1040100 | 10.40.100.0/24 | {"start": "10.40.100.10", "end": "10.40.100.253"} |
| ed517a74-736c-431d-8dd9-2b632395e6bb | 1040200 | 10.40.200.0/24 | {"start": "10.40.200.10", "end": "10.40.200.253"} |
| 419229d1-45d9-4aec-9fdf-e9fde3d58757 | 17216100 | 172.16.100.0/24 | {"start": "172.16.100.11", "end": "172.16.100.253"} |
| f7a13116-d091-4ad5-94fd-77a3c3f01ab5 | 1040150 | 10.40.150.0/24 | {"start": "10.40.150.10", "end": "10.40.150.253"} |
| f8b5705f-a45e-4498-bea4-8c104a873fab | 17216200 | 172.16.200.0/24 | {"start": "172.16.200.11", "end": "172.16.200.253"} |
+--------------------------------------+---------------------------------------------------+------------------+------------------------------------------------------+
查看17216150网段的详情,看到它使用的DNS为114
[root@controller1 ~]# neutron subnet-show 358321c0-6cbc-4ed7-a9e3-d8e7c3a6cf3a
+-------------------+-----------------------------------------------------+
| Field | Value |
+-------------------+-----------------------------------------------------+
| allocation_pools | {"start": "172.16.150.11", "end": "172.16.150.253"} |
| cidr | 172.16.150.0/24 |
| dns_nameservers | 114.114.114.114 |
| enable_dhcp | True |
| gateway_ip | |
| host_routes | |
| id | 358321c0-6cbc-4ed7-a9e3-d8e7c3a6cf3a |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | 17216150 |
| network_id | 2b32fcf5-1db9-4972-a077-219d520624a3 |
| subnetpool_id | |
| tenant_id | 18649c1da2594d31988fd26baf15252b |
+-------------------+-----------------------------------------------------+
修改它的DNS地址iP。还支持优先级。这个操作是覆盖型的。
neutron subnet-update 358321c0-6cbc-4ed7-a9e3-d8e7c3a6cf3a --dns_nameservers list=true 10.40.200.100 114.114.114.114
Updated subnet: 358321c0-6cbc-4ed7-a9e3-d8e7c3a6cf3a
[root@controller1 ~]# neutron subnet-show 358321c0-6cbc-4ed7-a9e3-d8e7c3a6cf3a
+-------------------+-----------------------------------------------------+
| Field | Value |
+-------------------+-----------------------------------------------------+
| allocation_pools | {"start": "172.16.150.11", "end": "172.16.150.253"} |
| cidr | 172.16.150.0/24 |
| dns_nameservers | 10.40.200.100 |
| | 114.114.114.114 |
| enable_dhcp | True |
| gateway_ip | |
| host_routes | |
| id | 358321c0-6cbc-4ed7-a9e3-d8e7c3a6cf3a |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | 17216150 |
| network_id | 2b32fcf5-1db9-4972-a077-219d520624a3 |
| subnetpool_id | |
| tenant_id | 18649c1da2594d31988fd26baf15252b |
+-------------------+-----------------------------------------------------+
此操作是针对要新建和启动的VM虚拟机有效,老的,已启动的VM,默认不会修改,可通过配置管理工具,比如saltstack,将服务器上的/etc/resolv.conf配置文件进行批量修改,并实时生效。
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,负责保留追究法律责任的权利。