虚拟机 ubuntu 12环境下设置静态IP

来源:互联网 发布:怎样在淘宝联盟买东西 编辑:程序博客网 时间:2024/06/06 15:40

我设置静态IP的目的有两点

1.想通过crt连接到虚拟机上,

2.可以网络映射驱动到该虚拟机从而可以使用source insight等编辑软件在window下进行操作。

下面是如何操作:

1、配置静态IP地址:

# vim /etc/network/interfaces

原内容有如下4行:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

以上表示默认使用DHCP分配IP,修改为如下:


auto lo
iface lo inet loopback

# The primary network interface
auto eth0
#iface eth0 inet dhcp

iface eth0 inet static
address 192.168.80.129
netmask 255.255.255.0
gateway 192.168.80.2

注意:在设置上述地址时,不能加入注释。

3、重启networking服务使其生效:

# /etc/init.d/networking restart


原创粉丝点击