1.ubuntu12.04的网络设置文件
vim /etc/network/interface
# The loopback network interface auto lo iface lo inet loopback
加入下面的配置
# The primary network interface auto eth0 iface eth0 inet static address 10.12.146.84 netmask 255.255.255.0 gateway 10.12.146.1
加入后查看该文件可可以看到
# 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 eth0 iface eth0 inet static address 10.12.146.84 netmask 255.255.255.0 gateway 10.12.146.1
加入该配置后网络还不能生效,需执行该命令
/etc/init.d/netwoking restart
2.修改dns配置
如果设置ip后不能连接外网,则可能需要修改dns配置(当然如果你配置了桥接方式)
执行命令
vim /etc/resolv.conf
加入如下dns配置
nameserver 8.8.8.8 nameserver 8.8.4.4
这两个地址是google提供dns解析地址
到目前为止linux网络配置就完成了
ps:这了还有一篇介绍的比较详细,贴出来 http://www.01happy.com/ubuntu-12-04-network-setting/