配置centos的静态ip 以及网关 Configure Static IP Address in CentOS
2015-10-22 11:15
639 查看
转载地址:http://www.mustbegeek.com/configure-static-ip-address-in-centos/
The following steps will show configuration of static IP address in CentOS machine.
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
You will see default configuration like this,
Now change the configuration to this,
Then save the file, to save press ctrl+x to exit and pressy for confirmation.
Now restart the network services by issuing the command,
[root@hostname~]# service network restart
To verify the IP address issue the following command,
[b][root@hostname~]# ifconfig
[/b]You will then see following information,
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.
The following steps will show configuration of static IP address in CentOS machine.
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
You will see default configuration like this,
Now change the configuration to this,
Then save the file, to save press ctrl+x to exit and pressy for confirmation.
Now restart the network services by issuing the command,
[root@hostname~]# service network restart
To verify the IP address issue the following command,
[b][root@hostname~]# ifconfig
[/b]You will then see following information,
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.
相关文章推荐
- linux中添加ssh用户
- eclipse 远程图形化调试嵌入式linux c arm(beaglebone black),解决常见调试问题
- Linux 新建用户、用户组,给用户分配权限(转载)
- linuxmint使用蓝牙串口
- linux下使用qq
- eclipse c +jre开发环境的建立(嵌入式linux,64位ubuntu,32位arm板)
- linux系统安装mysql
- Linux - 查看系统group
- 鸟哥的Linux私房菜-学习笔记-第三章【主机规划与磁盘分区】
- 超简单的卸载linux的方法
- aliyun的CentOS yum源
- linux常用命令1
- Linux下*.tar.gz文件解压缩命令
- linux 下安装nodejs,CentOS 6.5 系统
- CentOS下安装g++编译器
- Centos tmux 安装 与 配置
- Linux学习16_linux上ln命令详细说明
- android或linux调试addr2line工具锁定命令的使用
- Linux命令之 find
- Linux下添加新硬盘,分区及挂载