切换到root用户,然后进入/etc/network目录。备份interfaces文件(备份文件是一个好习惯)

下面编辑interfaces文件,添加如下语句:

 # Assgin static IP by eric on -SEP-
iface eth0 inet static
address 192.168.196.135 #change to your static IP
netmask 255.255.255.0 #change to your netmask
gateway 192.168.196.255 #change to your getway
#We must specify dns-nameserver here
#in order to get internet access from host
dns-nameservers 192.168.196.255
auto eth0

编辑完成后的interfaces文件内容如下:

root@ubuntu:/etc/network# cat interfaces
# interfaces() file used by ifup() and ifdown()
auto lo
iface lo inet loopback #add by andy at --
# Assgin static IP by eric on -SEP-
iface eth0 inet static
address 192.168.196.135 #change to your static IP
netmask 255.255.255.0 #change to your netmask
gateway 192.168.196.255 #change to your getway
#We must specify dns-nameserver here
#in order to get internet access from host
dns-nameservers 192.168.196.255
auto eth0

下一步就是重启网卡:

root@ubuntu:/etc/network# /etc/init.d/networking restart

重启完成后,测试一下:

 root@ubuntu:/etc/network# ping www.baidu.com.cn
PING www.a.shifen.com (220.181.112.244) () bytes of data.
bytes from 220.181.112.244: icmp_req= ttl= time=6.12 ms
bytes from 220.181.112.244: icmp_req= ttl= time=14.7 ms

OK。静态IP设置完成。

最新文章

  1. JSONP 理解 和 实例 讲解
  2. jquery.validate使用 - 自定义错误信息
  3. 如何 在远程虚拟机 里 破解 最新版 SQL Prompt
  4. kail2 linux 安装vmware tools
  5. linux资源使用配置文件 /etc/security/limits.conf和ulimit
  6. Hadoop.2.x_时间服务器搭建(CentOs6.6)
  7. [DFNews] GetData也出取证软件了
  8. 动态创建Layout
  9. 《Prism 5.0源码走读》Bootstrapper
  10. C开发 中原子性操作 , 除了快什么都不剩下了
  11. java基础之数据类型转换
  12. 解决Tomcat无法加载css和js等静态资源文件
  13. PHP打印各种金字塔!
  14. jquery val() and text().
  15. java中的类型转换
  16. C#语句 分支语句 if --- else ---
  17. CentOS7安装搭建.Net Core 2.0环境-详细步骤
  18. 【SPL标准库专题(10)】SPL Exceptions
  19. Ubuntu Linux系统环境变量配置文件
  20. 【PAT】1017 A除以B(20 分)

热门文章

  1. hibernate学习系列-----(4)hibernate基本查询上篇:HQL基本查询
  2. Laravel创建项目和安装PHPStorm IDE插件
  3. Servlet基本用法二接口和类
  4. 正则表达式Pattern ,Matcher
  5. 基于React的贪吃蛇游戏的设计与实现
  6. 对象序列和反序列化Xml
  7. ASP.NET中的配置文件
  8. scrapy框架爬取豆瓣读书(1)
  9. gopath基础概念
  10. linux进程状态详解(转)