当前位置:   article > 正文

Ubuntu搭建dhcpv6服务器(Kea DHCP Server V1.4.0)_ubutun 22.04 dhcpv6 server安装

ubutun 22.04 dhcpv6 server安装

按如下配置之后,SLAAC,Stateless DHCP,Statefull DHCP都可以工作,而且所有模式都支持PD。

  • 配置net.ipv6.conf.all.forwarding为1
  • 安装并配置RADVD,这个比较简单,就不再赘述了,配置如下:
  1. interface eth1 {
  2. AdvSendAdvert on;
  3. MinRtrAdvInterval 20;
  4. MaxRtrAdvInterval 60;
  5. AdvManagedFlag on;
  6. AdvOtherConfigFlag on;
  7. prefix 2001:10:10:10::/64{
  8. AdvOnLink on;
  9. AdvAutonomous off;
  10. AdvRouterAddr off;
  11. };
  12. RDNSS 2001:10:10:10::10
  13. {};
  14. };
  • DHCPv6服务器的配置文件如下):

注意:配置"interfaces"之后,还要在subnet6中配置"interface"

  1. // This is a basic configuration for the Kea DHCPv6 server. Subnet declarations
  2. // are mostly commented out and no interfaces are listed. Therefore, the servers
  3. // will not listen or respond to any queries.
  4. // The basic configuration must be extended to specify interfaces on which
  5. // the servers should listen. There are a number of example options defined.
  6. // These probably don't make any sense in your network. Make sure you at least
  7. // update the following, before running this example in your network:
  8. // - change the network interface names
  9. // - change the subnets to match your actual network
  10. // - change the option values to match your network
  11. //
  12. // This is just a very basic configuration. Kea comes with large suite (over 30)
  13. // of configuration examples and extensive Kea User's Guide. Please refer to
  14. // those materials to get better understanding of what this software is able to
  15. // do. Comments in this configuration file sometimes refer to sections for more
  16. // details. These are section numbers in Kea User's Guide. The version matching
  17. // your software should come with your Kea package, but it is also available
  18. // on Kea web page (http://kea.isc.org, click User's Guide, direct link for
  19. // stable version is http://kea.isc.org/docs/kea-guide.html).
  20. //
  21. // This configuration file contains only DHCPv6 server's configuration.
  22. // If configurations for other Kea services are also included in this file they
  23. // are ignored by the DHCPv6 server.
  24. {
  25. // DHCPv6 configuration starts here. This section will be read by DHCPv6 server
  26. // and will be ignored by other components.
  27. "Dhcp6": {
  28. // Add names of your network interfaces to listen on.
  29. "interfaces-config": {
  30. // You typically want to put specific interface names here, e.g. eth0
  31. // but you can also specify unicast addresses (e.g. eth0/2001:db8::1) if
  32. // you want your server to handle unicast traffic in addition to
  33. // multicast. (DHCPv6 is a multicast based protocol).
  34. "interfaces": [ "eth1" ]
  35. },
  36. // Kea support control channel, which is a way to receive management commands
  37. // while the server is running. This is a Unix domain socket that receives
  38. // commands formatted in JSON, e.g. config-set (which sets new configuration),
  39. // config-reload (which tells Kea to reload its configuration from file),
  40. // statistic-get (to retrieve statistics) and many more. For detailed
  41. // description, see Sections 9.12, 16 and 15.
  42. "control-socket": {
  43. "socket-type": "unix",
  44. "socket-name": "/tmp/kea-dhcp6-ctrl.sock"
  45. },
  46. // Use Memfile lease database backend to store leases in a CSV file.
  47. // Depending on how Kea was compiled, it may also support SQL databases
  48. // (MySQL and/or PostgreSQL) and even Cassandra. Those database backends
  49. // require more parameters, like name, host and possibly user and password.
  50. // There are dedicated examples for each backend. See Section 8.2.2 "Lease
  51. // Storage" for details.
  52. "lease-database": {
  53. "type": "memfile",
  54. "lfc-interval": 3600
  55. },
  56. // Kea allows storing host reservations in a database. If your network is
  57. // small or you have few reservations, it's probably easier to keep them
  58. // in the configuration file. If your network is large, it's usually better
  59. // to use database for it. To enable it, uncomment the following:
  60. // "hosts-database": {
  61. // "type": "mysql",
  62. // "name": "kea",
  63. // "user": "kea",
  64. // "password": "kea",
  65. // "host": "localhost",
  66. // "port": 3306
  67. // },
  68. // See Section 8.2.3 "Hosts storage" for details.
  69. // Setup reclamation of the expired leases and leases affinity.
  70. // Expired leases will be reclaimed every 10 seconds. Every 25
  71. // seconds reclaimed leases, which have expired more than 3600
  72. // seconds ago, will be removed. The limits for leases reclamation
  73. // are 100 leases or 250 ms for a single cycle. A warning message
  74. // will be logged if there are still expired leases in the
  75. // database after 5 consecutive reclamation cycles.
  76. "expired-leases-processing": {
  77. "reclaim-timer-wait-time": 10,
  78. "flush-reclaimed-timer-wait-time": 25,
  79. "hold-reclaimed-time": 3600,
  80. "max-reclaim-leases": 100,
  81. "max-reclaim-time": 250,
  82. "unwarned-reclaim-cycles": 5
  83. },
  84. // These parameters govern global timers. Addresses will be assigned with
  85. // preferred and valid lifetimes being 3000 and 4000, respectively. Client
  86. // is told to start renewing after 1000 seconds. If the server does not
  87. // respond after 2000 seconds since the lease was granted, a client is
  88. // supposed to start REBIND procedure (emergency renewal that allows
  89. // switching to a different server).
  90. "renew-timer": 1000,
  91. "rebind-timer": 2000,
  92. "preferred-lifetime": 3000,
  93. "valid-lifetime": 4000,
  94. // These are global options. They are going to be sent when a client requests
  95. // them, unless overwritten with values in more specific scopes. The scope
  96. // hierarchy is:
  97. // - global
  98. // - subnet
  99. // - class
  100. // - host
  101. //
  102. // Not all of those options make sense. Please configure only those that
  103. // are actually useful in your network.
  104. //
  105. // For a complete list of options currently supported by Kea, see
  106. // Section 8.2.9 "Standard DHCPv6 Options". Kea also supports
  107. // vendor options (see Section 7.2.10) and allows users to define their
  108. // own custom options (see Section 7.2.9).
  109. "option-data": [
  110. // When specifying options, you typically need to specify
  111. // one of (name or code) and data. The full option specification
  112. // covers name, code, space, csv-format and data.
  113. // space defaults to "dhcp6" which is usually correct, unless you
  114. // use encapsulate options. csv-format defaults to "true", so
  115. // this is also correct, unless you want to specify the whole
  116. // option value as long hex string. For example, to specify
  117. // domain-name-servers you could do this:
  118. // {
  119. // "name": "dns-servers",
  120. // "code": 23,
  121. // "csv-format": "true",
  122. // "space": "dhcp6",
  123. // "data": "2001:db8:2::45, 2001:db8:2::100"
  124. // }
  125. // but it's a lot of writing, so it's easier to do this instead:
  126. {
  127. "name": "dns-servers",
  128. "data": "2001:db8:2::45, 2001:db8:2::100"
  129. },
  130. // Typically people prefer to refer to options by their names, so they
  131. // don't need to remember the code names. However, some people like
  132. // to use numerical values. For example, DHCPv6 can optionally use
  133. // server unicast communication, if extra option is present. Option
  134. // "unicast" uses option code 12, so you can reference to it either
  135. // by "name": "unicast" or "code": 12. If you enable this option,
  136. // you really should also tell the server to listen on that address
  137. // (see interfaces-config/interfaces list above).
  138. {
  139. "code": 12,
  140. "data": "2001:db8::1"
  141. },
  142. // String options that have a comma in their values need to have
  143. // it escaped (i.e. each comma is preceded by two backslashes).
  144. // That's because commas are reserved for separating fields in
  145. // compound options. At the same time, we need to be conformant
  146. // with JSON spec, that does not allow "\,". Therefore the
  147. // slightly uncommon double backslashes notation is needed.
  148. // Legal JSON escapes are \ followed by "\/bfnrt character
  149. // or \u followed by 4 hexadecimal numbers (currently Kea
  150. // supports only \u0000 to \u00ff code points).
  151. // CSV processing translates '\\' into '\' and '\,' into ','
  152. // only so for instance '\x' is translated into '\x'. But
  153. // as it works on a JSON string value each of these '\'
  154. // characters must be doubled on JSON input.
  155. {
  156. "name": "new-posix-timezone",
  157. "data": "EST5EDT4\\,M3.2.0/02:00\\,M11.1.0/02:00"
  158. },
  159. // Options that take integer values can either be specified in
  160. // dec or hex format. Hex format could be either plain (e.g. abcd)
  161. // or prefixed with 0x (e.g. 0xabcd).
  162. {
  163. "name": "preference",
  164. "data": "0xf0"
  165. },
  166. // A few options are encoded in (length, string) tuples
  167. // which can be defined using only strings as the CSV
  168. // processing computes lengths.
  169. {
  170. "name": "bootfile-param",
  171. "data": "root=/dev/sda2, quiet, splash"
  172. }
  173. ],
  174. // Below an example of a simple IPv6 subnet declaration. Uncomment to enable
  175. // it. This is a list, denoted with [ ], of structures, each denoted with
  176. // { }. Each structure describes a single subnet and may have several
  177. // parameters. One of those parameters is "pools" that is also a list of
  178. // structures.
  179. "subnet6": [
  180. {
  181. // This defines the whole subnet. Kea will use this information to
  182. // determine where the clients are connected. This is the whole
  183. // subnet in your network. This is mandatory parameter for each
  184. // subnet.
  185. "subnet": "2001:20:20:20::/64",
  186. // Pools define the actual part of your subnet that is governed
  187. // by Kea. Technically this is optional parameter, but it's
  188. // almost always needed for DHCP to do its job. If you omit it,
  189. // clients won't be able to get addresses, unless there are
  190. // host reservations defined for them.
  191. "pools": [ { "pool": "2001:20:20:20::200-2001:20:20:20::ffff" } ],
  192. // Kea supports prefix delegation (PD). This mechanism delegates
  193. // whole prefixes, instead of single addresses. You need to specify
  194. // a prefix and then size of the delegated prefixes that it will
  195. // be split into. This example below tells Kea to use
  196. // 2001:db8:1::/56 prefix as pool and split it into /64 prefixes.
  197. // This will give you 256 (2^(64-56)) prefixes.
  198. "pd-pools": [
  199. {
  200. "prefix": "2001:db8:8::",
  201. "prefix-len": 56,
  202. "delegated-len": 64
  203. // Kea also supports excluded prefixes. This advanced option
  204. // is explained in Section 9.2.9. Please make sure your
  205. // excluded prefix matches the pool it is defined in.
  206. // "excluded-prefix": "2001:db8:8:0:80::",
  207. // "excluded-prefix-len": 72
  208. }
  209. ],
  210. "option-data": [
  211. // You can specify additional options here that are subnet
  212. // specific. Also, you can override global options here.
  213. {
  214. "name": "dns-servers",
  215. "data": "2001:20:20:20:20:20:20:20"
  216. },
  217. {
  218. "name": "link-address",
  219. "data": "2001:20:20:20::1"
  220. }
  221. ],
  222. // Host reservations can be defined for each subnet.
  223. //
  224. // Note that reservations are subnet-specific in Kea. This is
  225. // different than ISC DHCP. Keep that in mind when migrating
  226. // your configurations.
  227. "reservations": [
  228. // This is a simple host reservation. The host with DUID matching
  229. // the specified value will get an address of 2001:db8:1::100.
  230. {
  231. "duid": "01:02:03:04:05:0A:0B:0C:0D:0E",
  232. "ip-addresses": [ "2001:db8:1::100" ]
  233. },
  234. // This is similar to the previous one, but this time the
  235. // reservation is done based on hardware/MAC address. The server
  236. // will do its best to extract the hardware/MAC address from
  237. // received packets (see 'mac-sources' directive for
  238. // details). This particular reservation also specifies two
  239. // extra options to be available for this client. If there are
  240. // options with the same code specified in a global, subnet or
  241. // class scope, the values defined at host level take
  242. // precedence.
  243. {
  244. "hw-address": "00:01:02:03:04:05",
  245. "ip-addresses": [ "2001:db8:1::101" ],
  246. "option-data": [
  247. {
  248. "name": "dns-servers",
  249. "data": "3000:1::234"
  250. },
  251. {
  252. "name": "nis-servers",
  253. "data": "3000:1::234"
  254. }],
  255. // This client will be automatically added to certain
  256. // classes.
  257. "client-classes": [ "special_snowflake", "office" ]
  258. },
  259. // This is a bit more advanced reservation. The client with the
  260. // specified DUID will get a reserved address, a reserved prefix
  261. // and a hostname. This reservation is for an address that it
  262. // not within the dynamic pool. Finally, this reservation
  263. // features vendor specific options for CableLabs, which happen
  264. // to use enterprise-id 4491. Those particular values will be
  265. // returned only to the client that has a DUID matching this
  266. // reservation.
  267. {
  268. "duid": "01:02:03:04:05:06:07:08:09:0A",
  269. "ip-addresses": [ "2001:db8:1:cafe::1" ],
  270. "prefixes": [ "2001:db8:2:abcd::/64" ],
  271. "hostname": "foo.example.com",
  272. "option-data": [
  273. {
  274. "name": "vendor-opts",
  275. "data": "4491"
  276. },
  277. {
  278. "name": "tftp-servers",
  279. "space": "vendor-4491",
  280. "data": "3000:1::234"
  281. }
  282. ]
  283. },
  284. // This reservation is using flexible identifier. Instead of
  285. // relying on specific field, sysadmin can define an expression
  286. // similar to what is used for client classification,
  287. // e.g. substring(relay[0].option[17],0,6). Then, based on the
  288. // value of that expression for incoming packet, the reservation
  289. // is matched. Expression can be specified either as hex or
  290. // plain text using single quotes.
  291. // Note: flexible identifier requires flex_id hook library to be
  292. // loaded to work.
  293. {
  294. "flex-id": "'somevalue'",
  295. "ip-addresses": [ "2001:db8:1:cafe::2" ]
  296. }
  297. ],
  298. "interface": "eth1"
  299. }
  300. // More subnets can be defined here.
  301. // {
  302. // "subnet": "2001:db8:2::/64",
  303. // "pools": [ { "pool": "2001:db8:2::/80" } ]
  304. // },
  305. // {
  306. // "subnet": "2001:db8:3::/64",
  307. // "pools": [ { "pool": "2001:db8:3::/80" } ]
  308. // },
  309. // {
  310. // "subnet": "2001:db8:4::/64",
  311. // "pools": [ { "pool": "2001:db8:4::/80" } ]
  312. // }
  313. ]
  314. // Client-classes can be defined here. See "client-classes" in Dhcp4 for
  315. // an example.
  316. // Hook libraries can be defined here. See "hooks-libraries" example in
  317. // Dhcp4.
  318. // DDNS information (how the DHCPv6 component can reach a DDNS daemon)
  319. },
  320. // Logging configuration starts here. Kea uses different loggers to log various
  321. // activities. For details (e.g. names of loggers), see Chapter 18.
  322. "Logging":
  323. {
  324. "loggers": [
  325. {
  326. // This specifies the logging for kea-dhcp6 logger, i.e. all logs
  327. // generated by Kea DHCPv6 server.
  328. "name": "kea-dhcp6",
  329. "output_options": [
  330. {
  331. // Specifies the output file. There are several special values
  332. // supported:
  333. // - stdout (prints on standard output)
  334. // - stderr (prints on standard error)
  335. // - syslog (logs to syslog)
  336. // - syslog:name (logs to syslog using specified name)
  337. // Any other value is considered a name of a time
  338. "output": "/usr/local/var/log/kea-dhcp6.log"
  339. // This governs whether the log output is flushed to disk after
  340. // every write.
  341. // "flush": false,
  342. // This specifies the maximum size of the file before it is
  343. // rotated.
  344. // "maxsize": 1048576,
  345. // This specifies the maximum number of rotated files to keep.
  346. // "maxver": 8
  347. }
  348. ],
  349. // This specifies the severity of log messages to keep. Supported values
  350. // are: FATAL, ERROR, WARN, INFO, DEBUG
  351. "severity": "INFO",
  352. // If DEBUG level is specified, this value is used. 0 is least verbose,
  353. // 99 is most verbose. Be cautious, Kea can generate lots and lots
  354. // of logs if told to do so.
  355. "debuglevel": 0
  356. }
  357. ]
  358. }
  359. }

 
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号