我试图拦截来自将localhost指定为服务器的ubuntu计算机的NTP同步请求:
server 127.0.0.1
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
我从Qt程序构建一个套接字,并尝试绑定到localhost:123来拦截ntp同步请求。
m_NTPConnection = new QUdpSocket();
if (!m_NTPConnection->bind(QHostAddress::LocalHost, static_cast<quint16>(m_NTPPort), QAbstractSocket::ShareAddress)) {
Log(Logging::DebugLevel::ERROR, "Cannot bind to ntp socket");
}
不幸的是,我收到绑定连接错误QAbstractSocket :: AddressInUseError。当我使用sudo服务ntp stop停止ntp进程时,我被允许绑定。有谁知道我应该如何配置ntp以便可以拦截ntp同步请求?