$cat/etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version:2 renderer:NetworkManager ethernets: ens3: dhcp4:no dhcp6:yes mtu:8046 addresses: [192.168.128.123/22] nameservers: search: [sonnyhcl.top] addresses: [192.168.128.121, 192.168.128.122] # ens5: # dhcp4: no # dhcp6: yes # addresses: [10.141.209.177/20] # gateway4: 10.141.208.1
网络配置常用命令
1
sudo netplan --debug apply
安装步骤
下载 dhcp 包
1
sudo apt install -y isc-dhcp-server
配置 /etc/default/isc-dhcp-server
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)
# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf). DHCPDv4_CONF=/etc/dhcp/dhcpd.conf #DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
# Path to dhcpd's PID file (default: /var/run/dhcpd.pid). DHCPDv4_PID=/var/run/dhcpd.pid #DHCPDv6_PID=/var/run/dhcpd6.pid
# Additional options to start dhcpd with. # Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead #OPTIONS=""
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1". INTERFACESv4="ens3" INTERFACESv6=""
# dhcpd.conf # # Sample configuration file for ISC dhcpd # # Attention: If /etc/ltsp/dhcpd.conf exists, that will be used as # configuration file instead of this file. #
# option definitions common to all supported networks... option domain-name"sonnyhcl.top"; option domain-name-servers ipa.sonnyhcl.top, ipa02.sonnyhcl.top;
default-lease-time14400; max-lease-time172800;
# The ddns-updates-style parameter controls whether or not the server will # attempt to do a DNS update when a lease is confirmed. We default to the # behavior of the version 2 packages ('none', since DHCP v2 didn't # have support for DDNS.) ddns-update-style interim; ddns-updates on; ddns-domainname "sonnyhcl.top"; ddns-rev-domainname "in-addr.arpa";
zone 168.192.in-addr.arpa. { primary ipa.sonnyhcl.top; }
zone sonnyhcl.top. { primary ipa;}
subnet 192.168.128.0 netmask 255.255.252.0 { range 192.168.130.1192.168.131.254; default-lease-time14400; max-lease-time172800; zone sonnyhcl.top. { primary 192.168.128.2; } zone in-addr.arpa. { primary 192.168.128.2; } }
# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative;
# Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7;