首页 > 其他分享 >DHCP 和 DNS 示例

DHCP 和 DNS 示例

时间:2024-11-11 16:46:40浏览次数:1  
标签:set service 示例 dnsmasq DNS dhcp DHCP uci

DHCP 和 DNS 示例

https://openwrt.org/zh/docs/guide-user/base-system/dhcp_configuration

 

This article relies on the following:

See also: DHCP and DNS configurationDNS 加密DNS 劫持

本指南提供了适用于 OpenWrt 的最常见的 dnsmasq 和 odhcpd 调整方案。

 

LuCI → DHCP/DNS → 静态地址分配

为具有 MAC 地址的计算机添加固定 IPv4 地址 和名称 。 192.168.1.22mylaptop

uci add dhcp host
uci set dhcp.@host[-1].name="mylaptop"
uci set dhcp.@host[-1].dns='1'
uci set dhcp.@host[-1].mac="11:22:33:44:55:66"
uci set dhcp.@host[-1].ip="192.168.1.22"
uci commit dhcp
service dnsmasq restart

Reconnect your clients to apply the changes.

Add a fixed IPv6 interface identifier aka address suffix and name for a machine with the DUID . 23mylaptop000100004fd454041c6f65d26f43

uci add dhcp host
uci set dhcp.@host[-1].name="mylaptop"
uci set dhcp.@host[-1].dns='1'
uci set dhcp.@host[-1].duid="000100004fd454041c6f65d26f43"
uci set dhcp.@host[-1].hostid="23"
uci commit dhcp
service odhcpd restart

Reconnect your clients to apply the changes.

This is an implementation of the option. You can combine IPv4 and IPv6 reservations to a single host entry. Using multiple MACs per host entry is possible but unreliable. Add a separate host entry for each MAC if the host has more than one interface connected simultaneously. --dhcp-host

See also: odhcpd leases

Ignore DHCP requests from specific clients.

uci add dhcp host
uci set dhcp.@host[-1].name="mydesktop"
uci set dhcp.@host[-1].mac="00:11:22:33:44:55"
uci set dhcp.@host[-1].ip="ignore"
uci commit dhcp
service dnsmasq restart

Ignore all DHCP requests except the ones from known clients configured with static leases or . /etc/ethers

uci set dhcp.lan.dynamicdhcp="0"
uci commit dhcp
service dnsmasq restart

Avoid using this as a security measure since the client can still access the network with a static IP.

Resolve the race condition with netifd service and skip check for competing DHCP servers.

uci set dhcp.lan.force="1"
uci commit dhcp
service dnsmasq restart
 

Suppress warnings about missing GUA prefix.

uci set dhcp.odhcpd.loglevel="3"
uci commit dhcp
service odhcpd restart
   

Announce IPv6 default route for clients using the ULA prefix.

uci set dhcp.lan.ra_default="1"
uci commit dhcp
service odhcpd restart
 

DHCP options can be configured under the DHCP pool section via . Use an alternative default gateway, DNS server and NTP server, disable WINS. dhcp_option

uci add_list dhcp.lan.dhcp_option="3,192.168.1.2"
uci add_list dhcp.lan.dhcp_option="6,172.16.60.64"
uci add_list dhcp.lan.dhcp_option="42,172.16.60.64"
uci add_list dhcp.lan.dhcp_option="44"
uci commit dhcp
service dnsmasq restart

Use the classifier to create a tagged group. Assign individual DHCP options to hosts tagged with . Specify custom DNS and possibly other DHCP options. tagtag1

uci set dhcp.tag1="tag"
uci set dhcp.tag1.dhcp_option="6,8.8.8.8,8.8.4.4"
uci add dhcp host
uci set dhcp.@host[-1].name="j400"
uci set dhcp.@host[-1].mac="00:21:63:75:aa:17"
uci set dhcp.@host[-1].ip="10.11.12.14"
uci set dhcp.@host[-1].tag="tag1"
uci add dhcp host
uci set dhcp.@host[-1].name="j500"
uci set dhcp.@host[-1].mac="01:22:64:76:bb:18"
uci set dhcp.@host[-1].ip="10.11.12.15"
uci set dhcp.@host[-1].tag="tag1"
uci commit dhcp
service dnsmasq restart

Use the classifier to create a tagged group. Assign different DHCP options to hosts with matching MACs. Disable default gateway and specify custom DNSmac

uci set dhcp.mac1="mac"
uci set dhcp.mac1.mac="00:FF:*:*:*:*"
uci set dhcp.mac1.networkid="vpn"
uci add_list dhcp.mac1.dhcp_option="3"
uci add_list dhcp.mac1.dhcp_option="6,192.168.1.3"
uci commit dhcp
service dnsmasq restart

See also: Vendor-Specific Option Code 0x01 - Microsoft Disable NetBIOS Option

If you want to disable NetBIOS over TCP on Windows clients, it's possible with the following vendor-specific DHCP option:

  • DHCP Option 43 (Vendor Specific Information)
    • Vendor-specific Option Code (1 byte): 0x01 (Microsoft Disable NetBios Option)
    • Vendor-specific Option Length (1 byte): 0x04
    • Vendor-specific Option Data (4 bytes): See table below
Value Effect
0x00000000 Enable NetBIOS over TCP/IP
0x00000001 Ignore setting
0x00000002 Disable NetBIOS over TCP/IP

It needs to be pushed to clients who have the “MSFT 5.0” Vendor class identifier in their DHCP requests.

This can be achieved with the following configuration snippet:

uci set dhcp.msft="vendorclass"
uci set dhcp.msft.networkid="msft"
uci set dhcp.msft.vendorclass="MSFT"
uci add_list dhcp.msft.dhcp_option="vendor:MSFT,1,2i"
uci commit dhcp
service dnsmasq restart
  • 10.0.0.0 - network address
  • 255.0.0.0 - network mask
  • 10.22.0.1 - pool start
  • 10.22.0.254 - pool end
  • 22*2**16+1 - pool offset
  • 253 - pool limit
# ipcalc.sh 10.0.0.0 255.0.0.0 $((22*2**16+1)) 253
IP=10.0.0.0
NETMASK=255.0.0.0
BROADCAST=10.255.255.255
NETWORK=10.0.0.0
PREFIX=8
START=10.22.0.1
END=10.22.0.254
 
uci set dhcp.lan.start="$((22*2**16+1))"
uci set dhcp.lan.limit="253"
uci commit dhcp
service dnsmasq restart

LuCI → Network → Hostnames

Define a custom domain name and the corresponding PTR record - assigns the IPv4 address and IPv6 address to the domain name and construct an appropriate reverse records. You can also use this to rebind domain names. The init service merges all entries to an additional hosts file used with the option. 192.168.1.23fdce::23mylaptop--addn-hosts

uci add dhcp domain
uci set dhcp.@domain[-1].name="mylaptop"
uci set dhcp.@domain[-1].ip="192.168.1.23"
uci add dhcp domain
uci set dhcp.@domain[-1].name="mylaptop"
uci set dhcp.@domain[-1].ip="fdce::23"
uci commit dhcp
service dnsmasq restart

Be sure to set up static leases to avoid possible collisions due to race conditions.

This is an implementation of the option. Return for the domain and all its subdomains. --address10.10.10.1home

uci add_list dhcp.@dnsmasq[0].address="/home/10.10.10.1"
uci commit dhcp
service dnsmasq restart

This is an implementation of the option. Define an SRV record for SIP over UDP, with the default port of on the host , with a class of and a weight of . --srv-host5060pbx.mydomain.com010

uci add dhcp srvhost
uci set	dhcp.@srvhost[-1].srv="_sip._udp.mydomain.com"
uci set	dhcp.@srvhost[-1].target="pbx.mydomain.com"
uci set	dhcp.@srvhost[-1].port="5060"
uci set	dhcp.@srvhost[-1].class="0"
uci set	dhcp.@srvhost[-1].weight="10"
uci commit dhcp
service dnsmasq restart

This is an implementation of the option. A Canonical Name record specifies that a domain name is an alias for another domain, the “canonical” domain. Specify that the FTP server is on the same host as the web server. --cname

uci add dhcp cname
uci set dhcp.@cname[-1].cname="ftp.example.com"
uci set dhcp.@cname[-1].target="www.example.com"
uci commit dhcp
service dnsmasq restart

Be sure to set up hostnames since CNAME depends on it.

This is an implementation of the option. Mitigate the issues caused by split DNS for your own domain if you're running the mail server for your domain behind a firewall. Convince that mailer that it's actually authoritative for your domain, otherwise sendmail may not find an MX record to confirm that the domain is an MX relay and complain about non-existent domain of sender address. --mx-host

uci add dhcp mxhost
uci set	dhcp.@mxhost[-1].domain="yyy.zzz"
uci set	dhcp.@mxhost[-1].relay="my.host.com"
uci set	dhcp.@mxhost[-1].pref="10"
uci commit dhcp
service dnsmasq restart

Direct BOOTP requests to the TFTP server. Tell the client to load from the server at , and mount root from on the same server. pxelinux.0192.168.1.2/data/netboot/root

uci set dhcp.linux="boot"
uci set dhcp.linux.filename="/tftpboot/pxelinux.0"
uci set dhcp.linux.serveraddress="192.168.1.2"
uci set dhcp.linux.servername="fileserver"
uci add_list dhcp.linux.dhcp_option="option:root-path,192.168.1.2:/data/netboot/root"
uci commit dhcp
service dnsmasq restart

For PXE boot, each client needs a specific binary for its architecture e.g. PC BIOS, UEFI x86 32bit, UEFI x86 64bit, ARM, etc. You can match on the DHCP “Vendor Class Identifier” option (60) specified by the client to send back the right filename.

uci set dhcp.@dnsmasq[0].logdhcp='1'
uci set dhcp.@dnsmasq[0].enable_tftp='1'
uci set dhcp.@dnsmasq[0].tftp_root='/srv/tftp'
uci add dhcp match
uci set dhcp.@match[-1].networkid='bios'
uci set dhcp.@match[-1].match='60,PXEClient:Arch:00000'
uci add dhcp match
uci set dhcp.@match[-1].networkid='efi32'
uci set dhcp.@match[-1].match='60,PXEClient:Arch:00006'
uci add dhcp match
uci set dhcp.@match[-1].networkid='efi64'
uci set dhcp.@match[-1].match='60,PXEClient:Arch:00007'
uci add dhcp match
uci set dhcp.@match[-1].networkid='efi64'
uci set dhcp.@match[-1].match='60,PXEClient:Arch:00009'
uci add dhcp boot
uci set dhcp.@boot[-1].filename='tag:bios,bios/lpxelinux.0'
uci set dhcp.@boot[-1].serveraddress="$(uci get network.lan.ipaddr)"
uci set dhcp.@boot[-1].servername="$(uci get system.@system[0].hostname)"
uci add dhcp boot
uci set dhcp.@boot[-1].filename='tag:efi32,efi32/syslinux.efi'
uci set dhcp.@boot[-1].serveraddress="$(uci get network.lan.ipaddr)"
uci set dhcp.@boot[-1].servername="$(uci get system.@system[0].hostname)"
uci add dhcp boot
uci set dhcp.@boot[-1].filename='tag:efi64,efi64/syslinux.efi'
uci set dhcp.@boot[-1].serveraddress="$(uci get network.lan.ipaddr)"
uci set dhcp.@boot[-1].servername="$(uci get system.@system[0].hostname)"
uci commit dhcp
service dnsmasq reload

If you need multiple DNS forwarders with different configurations or DHCP server with different sets of lease files.

Running multiple dnsmasq instances as DNS forwarder and/or DHCPv4 server, each having their own configuration and lease list can be configured by creating multiple dnsmasq sections. Typically in such configs each dnsmasq section will be bound to a specific interface by using the interface list; assigning sections like , , etc. to a specific dnsmasq instance is done by the option. By default dnsmasq adds the loopback interface to the interface list to listen when the option is used; therefore the loopback interface needs to be excluded in one of the dnsmasq instances by using the notinterface list. dhcphostinstance--interface

These are example settings for multiple dnsmasq instances each having their own dhcp section. dnsmasq instance is bound to the interface while the dnsmasq instance is bound to the interface. lan_dnslanguest_dnsguest

# Remove default instances
while uci -q delete dhcp.@dnsmasq[0]; do :; done
while uci -q delete dhcp.@dhcp[0]; do :; done
 
# Use network interface names for DHCP/DNS instance names
INST="lan guest"
for INST in ${INST}
do
uci set dhcp.${INST}_dns="dnsmasq"
uci set dhcp.${INST}_dns.domainneeded="1"
uci set dhcp.${INST}_dns.boguspriv="1"
uci set dhcp.${INST}_dns.filterwin2k="0"
uci set dhcp.${INST}_dns.localise_queries="1"
uci set dhcp.${INST}_dns.rebind_protection="1"
uci set dhcp.${INST}_dns.rebind_localhost="1"
uci set dhcp.${INST}_dns.local="/${INST}/"
uci set dhcp.${INST}_dns.domain="${INST}"
uci set dhcp.${INST}_dns.expandhosts="1"
uci set dhcp.${INST}_dns.nonegcache="0"
uci set dhcp.${INST}_dns.authoritative="1"
uci set dhcp.${INST}_dns.readethers="1"
uci set dhcp.${INST}_dns.leasefile="/tmp/dhcp.leases.${INST}"
uci set dhcp.${INST}_dns.resolvfile="/tmp/resolv.conf.d/resolv.conf.auto"
uci set dhcp.${INST}_dns.nonwildcard="1"
uci add_list dhcp.${INST}_dns.interface="${INST}"
uci add_list dhcp.${INST}_dns.notinterface="loopback"
uci set dhcp.${INST}="dhcp"
uci set dhcp.${INST}.instance="${INST}_dns"
uci set dhcp.${INST}.interface="${INST}"
uci set dhcp.${INST}.start="100"
uci set dhcp.${INST}.limit="150"
uci set dhcp.${INST}.leasetime="12h"
done
uci -q delete dhcp.@dnsmasq[0].notinterface
uci commit dhcp
service dnsmasq restart

The LuCI web interface has not been updated to support multiple dnsmasq instances.

LuCI → 网络 → DHCP/DNS → 常规设置 → 记录查询日志

Log DNS queries for troubleshooting.

uci set dhcp.@dnsmasq[0].logqueries="1"
uci commit dhcp
service dnsmasq restart

See also: Reading logs

This change turns off DHCP on the specified interface but leaves DNS services available.

uci set dhcp.lan.ignore="1"
uci commit dhcp
service dnsmasq restart
service odhcpd restart

Stop advertising IPv6 DNS with DHCPv6/RA.

uci set dhcp.lan.dns_service="0"
uci set dhcp.lan.ra_dns="0"
uci commit dhcp
service odhcpd restart

This is useful when you just want to hand out addresses to clients, without doing any DNS by dnsmasq.

service dnsmasq stop
uci set dhcp.@dnsmasq[0].localuse="0"
uci set dhcp.@dnsmasq[0].port="0"
uci commit dhcp
service dnsmasq start

Remove dnsmasq and use odhcpd for both DHCP and DHCPv6.

opkg update
opkg remove dnsmasq odhcpd-ipv6only
opkg install odhcpd
uci -q delete dhcp.@dnsmasq[0]
uci set dhcp.lan.dhcpv4="server"
uci set dhcp.odhcpd.maindhcp="1"
uci commit dhcp
service odhcpd restart

对 DNS 使用 Unbound.

opkg update
opkg install unbound-control unbound-daemon
uci set unbound.@unbound[0].add_local_fqdn="3"
uci set unbound.@unbound[0].add_wan_fqdn="1"
uci set unbound.@unbound[0].dhcp_link="odhcpd"
uci set unbound.@unbound[0].dhcp4_slaac6="1"
uci set unbound.@unbound[0].unbound_control="1"
uci commit unbound
service unbound restart
uci set dhcp.odhcpd.leasetrigger="/usr/lib/unbound/odhcpd.sh"
uci commit dhcp
service odhcpd restart

See also: Unbound official documentation

LuCI → 网络 → 接口 → LAN → 编辑 → DHCP 服务器

  • 高级设置 → DHCP 选项
  • IPv6 设置 → 通告的 IPv6 DNS 服务器

使用 DHCP 通告自定义 DNS 服务器。

# Configure dnsmasq
uci -q delete dhcp.lan.dhcp_option
uci add_list dhcp.lan.dhcp_option="6,8.8.8.8,8.8.4.4"
uci commit dhcp
service dnsmasq restart
 
# Configure odhcpd
uci -q delete dhcp.lan.dns
uci add_list dhcp.lan.dns="2001:4860:4860::8888"
uci add_list dhcp.lan.dns="2001:4860:4860::8844"
uci commit dhcp
service odhcpd restart

重新连接您的客户端以应用更改。

See also: ISP DNS with DHCPIPv6 ISP DNS with DHCPv6

Answer DNS queries arriving from non-local networks. Reply to VPN clients using point-to-point topology.

uci set dhcp.@dnsmasq[0].localservice="0"
uci commit dhcp
service dnsmasq restart

禁用 DNS 缓存。

uci set dhcp.@dnsmasq[0].cachesize="0"
uci commit dhcp
service dnsmasq restart

LuCI → 网络 → DHCP/DNS → 常规设置 → DNS 转发

将DNS查询转发到特定服务器。

uci -q delete dhcp.@dnsmasq[0].server
uci add_list dhcp.@dnsmasq[0].server="8.8.8.8"
uci add_list dhcp.@dnsmasq[0].server="8.8.4.4"
uci commit dhcp
service dnsmasq restart

这可以与选择性 DNS 转发相结合。

LuCI → 网络 → DHCP/DNS → HOSTS 和解析文件 → 忽略解析文件

Ignore option and limit upstream resolvers to option. This effectively enables split DNS and makes the local system not to use dnsmasq. resolvfileserver

service dnsmasq stop
uci set dhcp.@dnsmasq[0].noresolv="1"
uci commit dhcp
service dnsmasq start

Enforce local system to use dnsmasq if it is running with option. Beware of race condition with Adblock service when using DNS encryption. noresolv

uci set dhcp.@dnsmasq[0].localuse="1"
uci commit dhcp
service dnsmasq restart

LuCI → 网络 → DHCP/DNS → 常规设置 → DNS 转发

Forward DNS queries for a specific domain and all its subdomains to a different server. More specific domains take precedence over less specific domains.

uci add_list dhcp.@dnsmasq[0].server="/example.com/192.168.2.1"
uci commit dhcp
service dnsmasq restart

This can be combined with unconditional DNS forwarding.

LuCI → 网络 → DHCP/DNS → 常规设置 → DNS 转发

Simple DNS-based content filtering.

# Blacklist
uci add_list dhcp.@dnsmasq[0].server="/example.com/"
uci add_list dhcp.@dnsmasq[0].server="/example.net/"
uci commit dhcp
service dnsmasq restart
 
# Whitelist
uci add_list dhcp.@dnsmasq[0].server="/example.com/#"
uci add_list dhcp.@dnsmasq[0].server="/example.net/#"
uci add_list dhcp.@dnsmasq[0].server="/#/"
uci commit dhcp
service dnsmasq restart

See also: Ad blockingDNS-based firewall with IP sets

Resolve the race condition with sysntpd service. When running dnsmasq with and options and using DNS encryption for local system. Fetch peer DNS or use a fallback DNS provider. Bypass DNS forwarding for NTP provider. noresolvlocaluse

. /lib/functions/network.sh
network_flush_cache
for IPV in 4 6
do eval network_find_wan${IPV%4} NET_IF
network_get_dnsserver NET_DNS "${NET_IF}"
case ${IPV} in
(4) NET_DNS="${NET_DNS:-8.8.8.8 8.8.4.4}" ;;
(6) NET_DNS="${NET_DNS:-2001:4860:4860::8888 2001:4860:4860::8844}" ;;
esac
for NET_DNS in ${NET_DNS}
do uci get system.ntp.server \
| sed -e "s/\s/\n/g" \
| sed -r -e "/\.pool\.ntp\.org$/s|^[0-9]*\.||;s|.*|\
del_list dhcp.@dnsmasq[0].server='/\0/${NET_DNS}'\n\
add_list dhcp.@dnsmasq[0].server='/\0/${NET_DNS}'|" \
| uci -q batch
done
done
uci commit dhcp
service dnsmasq restart

LuCI → 网络 → 接口 → WAN & WAN6 → 编辑

  • Use DNS servers advertised by peer
  • 使用自定义的 DNS 服务器

OpenWrt uses peer DNS as the upstream resolvers for dnsmasq by default. 这些通常由 ISP 上游 DHCP 服务器提供。 您可以将其更改为任何其他 DNS 提供商 或运行在其他主机上的本地 DNS 服务器。 如有必要,请使用支持 DNSSEC 验证的解析器。 指定多个解析器以提高容错能力。

# 配置 DNS 提供商
uci -q delete network.wan.dns
uci add_list network.wan.dns="8.8.8.8"
uci add_list network.wan.dns="8.8.4.4"
 
# 配置 IPv6 DNS 提供商
uci -q delete network.wan6.dns
uci add_list network.wan6.dns="2001:4860:4860::8888"
uci add_list network.wan6.dns="2001:4860:4860::8844"
 
# Disable peer DNS
uci set network.wan.peerdns="0"
uci set network.wan6.peerdns="0"
 
# 保存并应用
uci commit network
service network restart

一般注意事项

  • Resolvers from all active interfaces are combined in a single runtime configuration indiscriminately.
  • If the interface is down, its resolvers are not used, so it's reasonable to specify resolvers only on interfaces they are reachable from.
  • Dnsmasq 定期查询所有列出的解析器,然后在一段时间内使用最快的解析器。

多个 DNS 提供商

  • The more DNS providers, the higher the fault tolerance of your DNS relative to DoS.
  • Different DNS providers may return different answers to a DNS query due to differences in caching, synchronization, load balancing, content filtering, etc.
  • To distinguish between correct and incorrect answers such as false-negatives, you need to utilize DNSSEC which may negatively impact fault tolerance and performance.

Peer DNS options

  • Keep peer DNS enabled to improve your DNS fault tolerance.
  • Disable peer DNS to prevent DNS leaks if you have configured a VPN connection on OpenWrt.
  • Disable peer DNS to actually change your DNS provider and receive more predictable DNS replies.

 

============= End

 

标签:set,service,示例,dnsmasq,DNS,dhcp,DHCP,uci
From: https://www.cnblogs.com/lsgxeva/p/18540064

相关文章

  • QRust(四)示例程序
    这一章请跟随我对QRust项目携带的demo示例讲解,逐渐熟悉并掌握QRust的使用。无参数、无返回值的示例先从最简单示例foo()开始。Qt端:voidMainWindow::on_btn_foo_clicked(){ui->ptext_out->appendPlainText("-------------foo()-------------");Rustrust("foo")......
  • PHP爬虫快速获取京东商品详情(代码示例)
    在当今互联网时代,数据的重要性不言而喻。对于电商领域来说,获取商品信息是数据分析、市场研究和价格监控的基础。本文将介绍如何使用PHP编写一个简单的爬虫,以快速获取京东商品的详情信息。1.概述京东是中国领先的电商平台之一,拥有庞大的商品数据库。通过爬虫技术,我们可以自......
  • Python爬虫快速获取JD商品详情:代码示例与技巧解析
    在当今这个信息爆炸的时代,数据成为了一种宝贵的资源。对于电商行业来说,获取商品详情信息是进行市场分析、价格比较、库存管理等重要环节的基础。本文将通过一个Python爬虫示例,展示如何快速获取(JD)商品的详情信息。为什么选择Python进行爬虫开发?Python作为一种高级编程语言,以......
  • 鸿蒙网络编程系列 43- 仓颉版 HttpRequest 下载文件示例
    HttpRequest文件下载示例编写下面详细介绍创建该示例的步骤(确保DevEcoStudio已安装仓颉插件)。步骤1:创建[Cangjie]EmptyAbility项目。步骤2:在module.json5配置文件加上对权限的声明:"requestPermissions":[{"name":"ohos.permission.INTERNET"}]这里添加了访问......
  • C / C++ 整数类型转换规则与示例
    在C语言编程中,不同类型之间的转换是非常常见的事情,尤其是整数类型之间的转换,比如从较短类型到较长类型的转换、从有符号类型到无符号类型的转换等。这些转换看似简单,但如果不理解它们背后的机制,可能会导致一些隐蔽的bug。本文将深入探讨整数类型转换的规则和过程,并通过实例帮助大......
  • 物理约束➕深度学习代码示例
    好的,下面是一个结合物理机制与深度学习的示例代码。这个示例假设我们要预测土壤湿度(类似你的研究领域),并结合物理机制(例如,水的守恒)来改进模型的预测。示例:基于物理约束的土壤湿度预测模型在这个例子中,我们用深度学习模型预测土壤湿度,并在损失函数中加入水分守恒约束项,确保模型输......
  • 华为数据中心CE系列交换机级联M-LAG配置示例
    M-LAG组网简介M-LAG(Multi-chassisLinkAggregation)技术是一种跨设备的链路聚合技术,它通过将两台交换机组成一个逻辑设备,实现链路的负载分担和故障切换,从而提高网络的可靠性和稳定性。下面给大家详细介绍如何在华为交换机上进行M-LAG配置。在配置M-LAG之前,我们需要确认交换机......
  • OpenGL 和 GLSL 在顶点着色器中动态调整裁剪平面参数的简单代码示例
    以下是一个使用OpenGL和GLSL在顶点着色器中动态调整裁剪平面参数的简单代码示例://OpenGL初始化代码#include<GL/glew.h>#include<GLFW/glfw3.h>#include<iostream>GLFWwindow*window;//初始化GLFWvoidinitGLFW(){if(!glfwInit()){std::cer......
  • 基于KD树、包围盒与RayCast(射线投射)实现物体拾取的示例代码框架
    以下是一个基于KD树、包围盒与RayCast(射线投射)实现物体拾取的示例代码框架及相关解释。这个示例假设是在一个三维空间场景下进行操作,主要目的是通过从指定视点发出射线,利用KD树对场景中的物体包围盒进行组织和快速搜索,来判断射线与哪个物体相交,从而实现物体的拾取。#include<ios......
  • DHCP移植到瑞芯微RK356x平台
    dhcpd交叉编译1.简介项目中需要在RK3566上配置DHCP服务器,需要移植DHCP编译环境:Ubuntu20.04DHCP版本:v4.4.32.zlib移植dhcp交叉编译依赖libz.sozlib是一个广泛使用的开源数据压缩库,提供了数据压缩和解压缩的功能下载zlib源码,选择使用1.3.1版本,下载地址https://......