ubuntu设置有线上网

原有文件

xingfu@moon:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
xingfu@moon:~$ 
xingfu@moon:~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
search 202.103.24.68

配置

  1. 在命令行下输入sudo vi /etc/network/interfaces 打开文件,将其修改为:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.178
netmask 255.255.255.0
gateway 192.168.0.1

上面是设置静态的.
如果自动获取的话就如下:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

  1. 上面动态和静态都还要设置DNS 在命令行下输入sudo vi /etc/resolv.conf 打开这个文件
    ,把这一行 nameserver 61.144.56.100 放到里边去,要在第一行!

  2. 启网络:sudo /etc/init.d/networking restart

  3. 测试一下看设置是否成功:可以先看一下:在命令行下输入ifconfig 就能看到类似我这样的:
    eth0 Link encap:Ethernet HWaddr 00:16:76:3E:D3:5F
    inet addr:192.168.0.178 Bcast:192.168.0.255 Mask:255.255.255.0
    inet6 addr: fe80::216:76ff:fe3e:d35f/64 Scope:Link
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:200398 errors:0 dropped:0 overruns:0 frame:0
    TX packets:187200 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:235438130 (224.5 MiB) TX bytes:13786104 (13.1 MiB)

点击wireconnection 1连接即可!

参考文献

http://blog.chinaunix.net/uid-20789945-id-1841081.html

你可能感兴趣的:(ubuntu)