配置centos的静态ip 以及网关 Configure Static IP Address in CentOS

转载地址:http://www.mustbegeek.com/configure-static-ip-address-in-centos/



The following steps will show configuration of static IP address in CentOS machine.

  1. Files needed for network configuration are under /etc/sysconfig/network-scripts. So open the file with editor like nano or vi. Here I will use nano editor. After you start your server runningCentOS enter root user credentials and get in. Type the command,
    # nano /etc/sysconfig/network-scripts/ifcfg-eth0
  2. You will see default configuration like this,
    Configure Static IP Address in CentOS
  3. Now change the configuration to this,IP Address Changed
  4. Then save the file, to save press ctrl+x to exit and pressy for confirmation.
  5. Now restart the network services by issuing the command,
    [root@hostname~]# service network restart
  6. To verify the IP address issue the following command,
    [root@hostname~]# ifconfig
    You will then see following information,Configure Static IP Address in CentOS
  7. After configuring IP address now let’s configure DNS. Name server or DNS information is stored in different file. The location is,/etc/recolv.conf. Again using nano editor to configure DNS information,
    [root@hostname~]# nano /etc/resolv.conf

    By default, this file is empty, so enter at least one entry here,
    nameserver 4.2.2.2
    The name server IP address can be different depending on your network scenario. I will use www.google.com. Now save the file and exit. You can test the configuration by issuing ping command.

    [root@hostname~]# ping www.google.com

    If you get the reply, you have successfully configured the IP address and DNS information.

    Ping Reply


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值