在Debian系统上设置DHCP客户端相对简单。以下是详细的步骤:
sudo apt update
sudo apt install isc-dhcp-client
使用传统的/etc/network/interfaces
文件方式:
/etc/network/interfaces
。eth0
):auto eth0
iface eth0 inet dhcp
sudo systemctl restart networking
使用Netplan配置方式(适用于Debian 19.04及更高版本):
/etc/netplan/
目录下,例如01-netcfg.yaml
。network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
dhcp6: yes
sudo netplan apply
使用以下命令查看是否成功获取IP地址:
ip addr show eth0
或者使用ifconfig
(在较旧的Debian版本中):
ifconfig eth0
使用ping6
命令测试IPv6连接:
ping6 google.com
通过以上步骤,你应该能够在Debian系统上成功配置DHCP客户端。