- 编辑配置文件:
sudo nano /etc/network/interfaces - 修改内容(示例将 eth0 设为静态IP):
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4 # DNS服务器
Shift+Y保存
Ctrl+X 退出 - 重启网络服务:
sudo systemctl restart networking #
或sudo ifdown eth0 && sudo ifup eth0
或者
1.sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
2.BOOTPROTO=static # 使用静态IP
IPADDR=192.168.1.100 # 新IP地址NETMASK=255.255.255.0 # 子网掩码GATEWAY=192.168.1.1 # 网关DNS1=8.8.8.8 # DNS服务器ONBOOT=yes # 开机启用
3.重启网络服务:
sudo systemctl restart NetworkManager
或传统方式sudo systemctl restart network
1088

被折叠的 条评论
为什么被折叠?



