dnsmasq dhcp 中继不将响应从服务器中继回客户端?

问题描述

我有 3 个 VirtualBox 来宾操作系统,内部网络安排为:

Freeradius dhcprelay 客户端

  1. 内部网络:
    一种。 X 是 'tftprelay'
    湾Y 是 'tftpclient'

  2. Freeradius 作为 DHCP 服务器,接口面向 dhcprelay。 IP地址:10.10.254.1

  3. Dhcprelay 使用 dnsmasq。 还启用了数据包转发。

IP 地址:
一种。面对 FreeRadius 10.10.254.2
湾面对客户端 10.10.253.1

  1. 客户端只是普通的 debian 服务器。
    enp0s8 是 dnsmas 正在侦听的 network-Y 的接口

  2. 从 freeradius 到 network-Y 的 dhcprelay 的 ping 测试

    root@tftpserver:~# ping 10.10.253.1 PING 10.10.253.1 (10.10.253.1) 56(84) 字节数据。 来自 10.10.253.1 的 64 个字节:icmp_seq=1 ttl=64 time=1.08 ms 来自 10.10.253.1 的 64 个字节:icmp_seq=2 ttl=64 time=0.900 ms 来自 10.10.253.1 的 64 个字节:icmp_seq=3 ttl=64 time=1.07 ms 来自 10.10.253.1 的 64 字节:icmp_seq=4 ttl=64 time=0.904 ms 来自 10.10.253.1 的 64 字节:icmp_seq=5 ttl=64 time=1.15 ms

  3. 从客户端测试:dhclient -d enp0s8
    我得到:

一个。在 dhcprelay (dnsmasq 日志)

Jun 25 06:23:47 dhcprelay dnsmasq-dhcp[1366]: DHCP relay 10.10.253.1 -> 10.10.254.1
Jun 25 06:23:54 dhcprelay dnsmasq-dhcp[1366]: DHCP relay 10.10.253.1 -> 10.10.254.1
Jun 25 06:24:08 dhcprelay dnsmasq-dhcp[1366]: DHCP relay 10.10.253.1 -> 10.10.254.1
Jun 25 06:24:26 dhcprelay dnsmasq-dhcp[1366]: DHCP relay 10.10.253.1 -> 10.10.254.1
Jun 25 06:24:41 dhcprelay dnsmasq-dhcp[1366]: DHCP relay 10.10.253.1 -> 10.10.254.1

B.自由半径。看起来它可以从/向 dnsmasq 接收和响应:

...  
(5) Received code 1025 Id 1472493331 from 10.10.253.1:67 to 10.10.254.1:67 length 300 
(5)   DHCP-Opcode = Client-Message
(5)   DHCP-Hardware-Type = Ethernet
(5)   DHCP-Hardware-Address-Length = 6
(5)   DHCP-Hop-Count = 1
(5)   DHCP-Transaction-Id = 1472493331
(5)   DHCP-Number-of-Seconds = 51
(5)   DHCP-Flags = 0
(5)   DHCP-Client-IP-Address = 0.0.0.0
(5)   DHCP-Your-IP-Address = 0.0.0.0
(5)   DHCP-Server-IP-Address = 0.0.0.0
(5)   DHCP-Gateway-IP-Address = 10.10.253.1
(5)   DHCP-Client-Hardware-Address = 08:00:27:84:51:1b
(5)   DHCP-Message-Type = DHCP-discover
(5)   DHCP-Hostname = "bakalandebian"
(5)   DHCP-Parameter-Request-List = DHCP-subnet-Mask
(5)   DHCP-Parameter-Request-List = DHCP-broadcast-Address
(5)   DHCP-Parameter-Request-List = DHCP-Time-Offset
(5)   DHCP-Parameter-Request-List = DHCP-Router-Address
(5)   DHCP-Parameter-Request-List = DHCP-Domain-Name
(5)   DHCP-Parameter-Request-List = DHCP-Domain-Name-Server
(5)   DHCP-Parameter-Request-List = DHCP-Domain-Search
(5)   DHCP-Parameter-Request-List = DHCP-Hostname
(5)   DHCP-Parameter-Request-List = DHCP-NETBIOS-Name-Servers
(5)   DHCP-Parameter-Request-List = DHCP-NETBIOS
(5)   DHCP-Parameter-Request-List = DHCP-Interface-MTU-Size
(5)   DHCP-Parameter-Request-List = DHCP-Classless-Static-Route
(5)   DHCP-Parameter-Request-List = DHCP-NTP-Servers
(5)   DHCP-Client-Identifier = 0xff2784511b000100012867cc8108002784511b
(5)   DHCP-Network-subnet = 10.10.253.1/32
...
(5) DHCP: Reply will be unicast to giaddr from original packet
(5) Sent code 1026 Id 1472493331 from 10.10.254.1:67 to 10.10.253.1:67 length 0 
(5)   DHCP-Relay-IP-Address = 10.10.253.1
(5)   DHCP-Client-Identifier = 0xff2784511b000100012867cc8108002784511b
(5)   DHCP-IP-Address-Lease-Time = 7200
(5)   DHCP-Client-IP-Address = 255.255.255.255
(5)   DHCP-Your-IP-Address = 10.10.253.3
(5)   DHCP-subnet-Mask = 255.255.255.0
(5)   DHCP-Router-Address = 10.10.253.1
(5)   DHCP-Domain-Name-Server = 8.8.8.8
(5)   DHCP-Message-Type = DHCP-Offer
(5)   DHCP-Gateway-IP-Address = 10.10.253.1
(5)   DHCP-DHCP-Server-Identifier = 10.10.253.1
(5)   DHCP-Server-IP-Address = 10.10.254.1
(5)   DHCP-Opcode = Server-Message
(5)   DHCP-Hardware-Type = Ethernet
(5)   DHCP-Hardware-Address-Length = 6
(5)   DHCP-Hop-Count = 1
(5)   DHCP-Transaction-Id = 1472493331
(5)   DHCP-Flags = 0
(5)   DHCP-Client-Hardware-Address = 08:00:27:84:51:1b
    DHCP-Opcode = Server-Message
    DHCP-Hardware-Type = Ethernet
    DHCP-Hardware-Address-Length = 6
    DHCP-Hop-Count = 1
    DHCP-Transaction-Id = 1472493331
    DHCP-Number-of-Seconds = 0
    DHCP-Flags = 0
    DHCP-Client-IP-Address = 255.255.255.255
    DHCP-Your-IP-Address = 10.10.253.3
    DHCP-Server-IP-Address = 10.10.254.1
    DHCP-Gateway-IP-Address = 10.10.253.1
    DHCP-Client-Hardware-Address = 08:00:27:84:51:1b
    DHCP-Server-Host-Name = ""
    DHCP-Boot-Filename = ""
    DHCP-subnet-Mask = 255.255.255.0
    DHCP-Router-Address = 10.10.253.1
    DHCP-Domain-Name-Server = 8.8.8.8
    DHCP-IP-Address-Lease-Time = 7200
    DHCP-DHCP-Server-Identifier = 10.10.253.1
    DHCP-Client-Identifier = 0xff2784511b000100012867cc8108002784511b
Sending DHCP-Offer Id 57c47713 from 10.10.254.1:67 to 10.10.253.1:67
(5) Finished request
(5) Cleaning up request packet ID 1472493331 with timestamp +296
Ready to process requests

c.但在客户端:

Listening on LPF/enp0s8/08:00:27:84:51:1b
Sending on   LPF/enp0s8/08:00:27:84:51:1b
Sending on   Socket/fallback
DHCPdisCOVER on enp0s8 to 255.255.255.255 port 67 interval 6
DHCPdisCOVER on enp0s8 to 255.255.255.255 port 67 interval 15
DHCPdisCOVER on enp0s8 to 255.255.255.255 port 67 interval 21
DHCPdisCOVER on enp0s8 to 255.255.255.255 port 67 interval 8
DHCPdisCOVER on enp0s8 to 255.255.255.255 port 67 interval 10
DHCPdisCOVER on enp0s8 to 255.255.255.255 port 67 interval 1
No DHCPOFFERS received.
No working leases in persistent database - sleeping.

我的问题是:
我确定是 freeradius 发送了响应,但如何知道 dnsmasq 是否收到该响应?

我的 dnsmasq 配置

port=0
interface=enp0s9
log-dhcp
dhcp-relay=10.10.253.1,10.10.254.1

我的 freeradus dhcp 服务器配置:

server dhcp {
listen {
        type = dhcp
        ipaddr = 10.10.254.1
        src_ipaddr = 10.10.254.1
        port = 67
        broadcast = no
        performance {
            skip_duplicate_checks = no
        }
}
dhcp DHCP-discover {
    rest.authorize
}

dhcp DHCP-Request {
    rest.authorize
}
dhcp DHCP-Decline {
    update reply {
           &DHCP-Message-Type = DHCP-Do-Not-Respond
    }
    reject
}
dhcp DHCP-Inform {  
    dhcp_common
    ok
}
dhcp DHCP-Release {
    rest.authorize
}
dhcp DHCP-Lease-Query {
    if (&DHCP-Client-Hardware-Address) {
        
    }
    elsif (&DHCP-Your-IP-Address) {
        
    }
    elsif (&DHCP-Client-Identifier) {       
    }
    else {
        update reply {
            &DHCP-Message-Type = DHCP-Lease-UnkNown
        }
        ok
        return
    }
    if (notfound) {
        update reply {
            &DHCP-Message-Type = DHCP-Lease-UnkNown
        }
        ok
        return
    }
    update reply {
        &DHCP-Message-Type = DHCP-Lease-Unassigned
    }
}

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)