linux静态ip配置

在linux服务器上配置静态ip

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