# 使用 ifconfig 命令配置 IP 地址(适用于较旧的系统)
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
# 解释:
# sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
# 这条命令将网卡 eth0 的 IP 地址设置为 192.168.1.100,子网掩码为 255.255.255.0。
# 使用 ip 命令配置 IP 地址(推荐用于较新的系统)
sudo ip addr add 192.168.1.100/24 dev eth0
# 解释:
# sudo ip addr add 192.168.1.100/24 dev eth0
# 这条命令同样将网卡 eth0 的 IP 地址设置为 192.168.1.100,子网掩码为 255.255.255.0(用 /24 表示)。
# 使配置生效并重启网络服务
sudo systemctl restart networking
# 解释:
# sudo systemctl restart networking
# 这条命令会重启网络服务,使新的 IP 配置生效。
如果你使用的是较新的 Linux 发行版,建议使用 ip 命令来配置 IP 地址。
上一篇:linux ntpdate
下一篇:linux目录权限
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站