gedit /etc/network/interfaces
用如下代码覆盖:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth1
iface eth1 inet static
address 192.168.65.140(前三位必须和刚刚在vm中看到的address相同)
gateway 192.168.65.176(和刚刚看到的相同网关相同)
netmask 255.255.255.0
接下来网关再次配置gedit /etc/resolv.conf,添加这行:
nameserver 192.168.65.176(要和上面的网关一致)
ok,重启网卡:/etc/init.d/networking restart
出现以下提示:
* Reconfiguring network interfaces... ssh stop/waiting
ssh start/running, process 10360
设置完成!
到此为止我的虚拟机已经固定IP为192.168.65.140,网关:192.168.65.176,可以与宿主系统交互,可以访问外网。