skyline888 发表于 2013-2-7 07:55:04

linux

1.设置IP,
终端输入 sudo gedit /etc/network/interfaces
假设实用的是网卡0,如果是其它网卡就将eth0改为对应的值。
auto lo
iface lo inet loopback
#使用网卡0
auto eth0
#使用静态IP
iface eth0 inet static
#设置IP
address 172.32.1.11
#设置子网掩码,不要弄错了,可以自己算的,具体可能不一样的,由IP决定!
netmask 255.255.0.0
#设置网关
gateway 172.32.1.215

2.配置DNS
如果需要手动配置DNS
终端输入sudovi /etc/resolv.conf
在其中加入以下代码(211.153.31.2换为你的DNS)
nameserver 211.153.31.2

3.重启网络
sudo /etc/init.d/networking restart
提示ok之后可以试试能否ping到网关和局域网内的其它机器,然后再试试能否上网!


====================================================================
装完ubuntu 第一件事情就是连上网,换个源,进行更新操作,但前提条件是要配好ip和dns。
下面把自己配置的过程记录下来,权且当作一份备份,以便不时之需。

一、配置ip
   ubuntu的网络配置信息放在 /etc/network/interfaces 中,
   
   如果配置动态获取ip,则在上述文件中加入以下内容:
   auto eth0
   iface eth0 inet dhcp

   如果配置静态ip,则添加如下内容:
   auto eth0
   iface eth0 inet static
   address 192.168.33.201
   netmask 255.255.255.0
   gateway 192.168.33.1

   要是配置生效,需要重启网卡:
   ifconfig eth0 down
   ifconfig eth0 up
   
   不是root,命令前面加sudo
   
   接着用ifconfig命令查看ip是否配置成功

若还有没有配置成功,则需重启下网络服务
             /etc/init.d/networking restart

二、配置dns服务器
         ubuntu 的dns服务器信息,放在 /etc/resolv.conf中,
         添加dns服务器地址,如202.112.125.53,则在上述文件中加入
             nameserver202.112.125.53
小结:
       只要按上面的步骤配置完,就能上网了,如果还不行就重启下机器试试。
ifconfig eth0 {ip} netmask {子网掩码} broadcast {广播地址}

Ubuntu下配置静态IP
http://jwinder.iteye.com/blog/697599
页: [1]
查看完整版本: linux