Chinaunix首页 | 论坛 | 博客
  • 博客访问: 108644
  • 博文数量: 35
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 287
  • 用 户 组: 普通用户
  • 注册时间: 2015-08-01 19:56
文章分类
文章存档

2017年(6)

2016年(21)

2015年(8)

我的朋友

分类: LINUX

2017-03-04 09:55:11

功能介绍:自己项目放在虚拟机上,之前设置的自动获取IP地址,但是,麻烦的是,每次通过ssh连接的时候,都得更改ip地址,所以有点麻烦,如何将Ubuntu设置为静态IP,可以省去IP地址的跳动,当通过xshell或者phpstorm连接虚拟机的时候,不至于重新输入IP地址连接。

设置静态IP

1.编辑/etc/network/interfaces文件:

vim  /etc/network/interfaces //可以看到如下内容 # The primary network interface auto eth0 #iface eth0 inet dhcp //dhcp为自动的,将这行注释掉

2.在上述文件中添加如下内容:

iface eth0 inet static //static为静态的 address 192.168.3.101 //ip地址 netmask 255.255.255.0 //子网掩码 gateway 192.168.3.1 //网关 broadcast 192.168.3.255 //广播
  1. 编辑/etc/resolv.conf,设置相应的DNS

nameserver 202.96.134.133 #nameserver 8.8.8.8 //谷歌dns解析,但是速度较慢
  1. 重启网卡

/etc/init.d/networking restart

设置动态IP

1.修改/etc/network/interfaces

//修改成如下内容 auto eth0
iface eth0 inet DHCP 

2.重启网卡

/etc/init.d/networking restart
阅读(1227) | 评论(0) | 转发(0) |
0

上一篇:Ubuntu 不能上网

下一篇:动态函数库

给主人留下些什么吧!~~