ubuntu 网络配置(包括有线、无线、wifi)

int32位 posted @ 12 年前 in linux , 16623 阅读
转载请注明:http://krystism.is-programmer.com/若有错误,请多多指正,谢谢!

首先不得不说ubuntu下的network-manager有多不好,往往出现dhcp无法获取ip,锐捷无法认证等一系列问题。于是很果断的卸载了。

linux下网络配置分为有线和无线。

有线配置的话,如果是dhcp,修改/etc/network/interfaces 文件,看起来想这样

1
2
auto eth0
iface eth0 inet dhcp

其中auto表示在系统启动时脚本会自动开启,eth0是网卡名,在终端上输入

1
sudo ifconfig -a

可以查看所有计算机存在的网卡。具体查看man手册。

有时尽管我们设置了dhcp,但依然获取ip失败,这时可以运行dhclient命令

1
dhclient eth0 # ech0 替换成网卡名

然后再运行ifconfig查看是否正确获取了ip。

如果是静态ip,则看起来想这样

1
2
3
iface  inet static
address 192.168.1.1
netmask 255.255.255.0

当然要自启动也要在前面加入auto eth0. 有时需要配置网关和DNS,只需在下面加上gateway address 和 dns-nameservers address1, address2, DNS也可以在/etc下修改resolve.conf文件设置,看起来像这样:

1
2
nameserver 8.8.8.8
nameserver 202.196.64.1

注意:所有的配置都需要重启网络才生效!

如果网卡没有打开,需要运行sudo ifconifg eth0 up (eth0替换成网卡名)。

自此有线配置基本完成。

下面看看无线网络的配置。

首先无线网络,首先要开启无线(硬件开启),有时硬件开启时运行ifconifg也打不开,这可能因为是软件禁止了。运行:

1
rfkill list

可以查看软件禁止/开启列表,需要开启,只需运行

1
2
rfkill unblock index | type
# index 就是rfkill list 列表的编号, type 对应名字,比如wifi

然后配置/etc/network/interfaces 文件,与有线配置类似。

如果需要使用wifi,可以安装wifi-radar,这是个图形化工具。请确保wifi硬件和软件都已正常开启。

还有一个无线配置命令是iwconfig,请man之。

转载请注明:http://krystism.is-programmer.com/若有错误,请多多指正,谢谢!
  • 无匹配
  • 无匹配
Clay Lowe 说:
2025年1月11日 02:50

I wrote about a similar issue, I give you the link to my site.  Kissimmee Bed Bug Control

Clay Lowe 说:
2025年3月06日 19:40

Can nicely write on similar topics! Welcome to      here you'll find out how it should look. Massage therapy Langley

Clay Lowe 说:
2025年3月06日 19:43

Very interesting information, worth recommending. However, I recommend this:  Glass Bottles Canada

Clay Lowe 说:
2025年3月10日 16:07

I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. Get a free trial

Clay Lowe 说:
2025年3月11日 13:18

I might suggest solely beneficial in addition to trusted facts, and so find it: Permanent laser hair removal st albert

Clay Lowe 说:
2025年3月11日 13:28

Hi there, I discovered your blog per Google bit searching for such kinda educational advise moreover your inform beholds very remarkable for me. Junk Car removal Edmonton

Clay Lowe 说:
2025年3月18日 00:45

Very good topic, similar texts are       I do not know if they are as good as your work out. 作业代写

Clay Lowe 说:
2025年3月18日 20:17

For this web site, you will see our account, remember to go through this info. Parking lot line painting near me

Clay Lowe 说:
2025年3月18日 20:17

On that website page, you'll see your description, why not read through this. Barrie pest Control

Clay Lowe 说:
2025年3月18日 20:17

Interestingly you write, I will address        you'll find exciting and interesting things on similar topics. Best natural Soap

Clay Lowe 说:
2025年3月23日 20:30

I've proper selected to build a blog, which I hold been deficient to do for a during. Acknowledges for this inform, it's really serviceable! r6 sensitivity calculator


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter