关于新增dnsmasq --help的option选项

21 篇文章 0 订阅
1 篇文章 0 订阅

在拉起dnsmasq进程时,可以根据需要使能option选项,这些option选项并不是随心所遇的字符串,而是在dnsmasq代码中已经定义好的一部分,因此如果你想增加新的option选项,必须修订dnsmasq的相关代码。

举个例子:当你执行dnsmasq --help时可以看到类似如下配置

root@iZbp1f4tnw2sehghtpe5zpZ:~# dnsmasq --help
Usage: dnsmasq [options]

Valid options are:
-a, --listen-address=<ipaddr>                          Specify local address(es) to listen on.
-A, --address=/<domain>/<ipaddr>                       Return ipaddr for all hosts in specified domains.
-b, --bogus-priv                                       Fake reverse 
...

而些信息则是通过dnsmasq工程中的:
option.c文件中的
一个静态函数:static void do_usage(void)
打印出来。
具体的结构体在如下位置:

static struct {
  int opt;
  unsigned int rept;
  char * const flagdesc;
  char * const desc;
  char * const arg;
} usage[] = {
  { 'a', ARG_DUP, "<ipaddr>",  gettext_noop("Specify local address(es) to listen on."), NULL },
  { 'A', ARG_DUP, "/<domain>/<ipaddr>", gettext_noop("Return ipaddr for all hosts in specified domains."), NULL },

直接定义一个结构体数组,因此我们需要新增一个配置,可以仿照原先的逻辑在该数组新增一个结构体成员。
比如我新增一个nd代答的方法:
#define LOPT_ND_PROXY 357
新增
{ “nd-proxy”, 0, 0, LOPT_ND_PROXY },

在dnsmasq.h新增如下配置:
#define OPT_ND_PROXY 60

最后需要在one_opt(int option, char *arg, char *errstr, char *gen_err, int command_line, int servers_only)
新增一个关于该配置的case 选项

拉起进程:dnsmasq --no-hosts --no-resolv --strict-order --nd-proxy --except-interface=lo --dhcp-option-force=option:mtu,1500 --dhcp-lease-max=256 --domain=openstacklocal

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

举世无双勇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值