Ubuntu配置IP

1 修改配置interfaces文件

1.1 打开文件

命令:

sudo vim /etc/network/interfaces

1.2 在原内容下添加内容

光标滑到最后一行,按“o”键添加行。

加入:

auto eth0          
iface eth0 inet static  
address 10.214.161.240     
netmask 255.255.255.0      #子网掩码
gateway 10.214.161.1        #默认网关

其中,

eth0 为网卡号,需要自行修改为你自己的。
address 为IP地址,自行设置。
netmask 为子网掩码,一般默认为255.255.255.0,不用改。
gateway 为网关,需要自行修改为你自己的。

2 修改DNS

2.1 打开文件

命令:

sudo vim /etc/resolve.conf

2.2 修改文件

nameserver 127.0.0.1
nameserver 8.8.8.8

其中,

第一行一般是默认的,
第二行需要修改为你自己的DNS服务器。

3 重启网络

命令:

sudo /etc/init.d/networking restart

4 重新查看并确认配置

命令:

ifconfig -a

Ubuntu配置IP
看到 inet addr 为我们先前配置的ip,说明已经配置成功。

5 若还未成功

根据本人血泪的教训,若还未成功,试试:

1. 确认网线是未损坏的。 2. 确认接口是正常的,包括主机和交换机的接口。 3. 重启试试。