Kali Linux 网络配置教程:静态 IP 和 DHCP 设置
- 打开终端,输入命令
ifconfig确认网卡名称(一般为eth0或wlan0)和 IP 地址。 - 输入命令
vi /etc/network/interfaces进入编辑模式,将文件修改如下:
auto eth0
iface eth0 inet dhcp
说明:auto eth0 表示在启动时自动启用 eth0 网卡,iface eth0 inet dhcp 表示使用 DHCP 方式获取 IP 地址。
- 输入命令
service networking restart重启网络服务。 - 输入命令
ping www.baidu.com测试网络连接是否正常。
如果需要静态 IP 地址,可以将上述配置文件中的 dhcp 改为 static,并添加以下内容:
address IP 地址
netmask 子网掩码
gateway 默认网关
例如:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
修改完成后同样需要重启网络服务。
原文地址: https://www.cveoy.top/t/topic/nnlq 著作权归作者所有。请勿转载和采集!