- 使用命令
ifconfig
查看网卡名字,默认服务器网卡名为ifcfg-enth0
。 - 在/etc/sysconfig/network-scripts目录下,找到与网卡名字相同的文件。
- 修改该配置文件,修改内容如下:
1 2 3 4 5
IPADDR = 192.168.177.11 NETMASK = 255.255.255.0 GATEWAY = 192.168.177.1 BOOTPROTO = static ONBOOT = yes
- 重新启动网卡:
service network.service restart
或者systemctl network restart
- 测试网络通不通: ping www.baidu.com