主要配置文件:
/etc/network/interfaces
/etc/resolv.conf
/etc/hosts 、/etc/hostname
设置自动获取IP
sudo ifconfig eth0 down
sudo ifconfig eth0 up
sudo dhclient eth0
执行完上述命令以后,查看/etc/network/interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
#iface eth0 inet static
查看/etc/resolv.conf
nameserver 192.168.200.200
nameserver 192.168.200.240
修改主机名:
同时修改/etc/hosts 、/etc/hostname这两个文件即可
设置自定义IP
sudo ifconfig eth0 down
sudo ifconfig eth0 up
sudo ifconfig eth0 192.168.10.222 netmask 255.255.255.0
sudo route add default gw
执行完上述命令以后,查看/etc/network/interfaces
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.
# The loopback network interface
auto lo
iface lo inet loopback"
# The primary network interface
#auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 192.168.10.222
netmask 255.255.255.0
gateway 192.168.10.1
auto eth0
关于无线WIFI,设备名称ra0:
其实配置IP,DNS,流程和有线是一样的,主要是和无线路由器连接
用命令sudo iwlist ra0 scan 即可搜索出范围内的所有无线网络名称
我们可以使用命令
通过查看wireless.txt我们需要用到几个关键值:
Address , ssid ,Encryption
如果没有加密的无线网络(名称为test1)
sudo eth0 down
sudo ra0 down
sudo killall wpa_supplicant
sudo ra0 up
sudo iwconfig
sudo dhclient ra0
即可
假设:如果WEP 64/128-bit Hex 加密的无线网络(名称为test2),密码为1234567890 ,ADDRESS为 E0:15:22:42:28
sudo eth0 down
sudo ra0 down
sudo killall wpa_supplicant
sudo ra0 up
sudo iwconfig
1:如果Encryption 职位on
sudo iwconfig ra0 key open
sudo iwconfig ra0 key 1234567890
sudo iwconfig ra0 ap E0:15:22:42:28
sudo iwconfig ra0 rate auto
sudo dhclient ra0
2:如果Encryption 职位off
sudo iwconfig ra0 key off
sudo iwconfig ra0 ap E0:15:22:42:28
sudo iwconfig ra0 rate auto
sudo dhclient ra0
=========================================================================================
假设:如果WEP 64/128-bit Ascii 加密的无线网络(名称为test2),密码为1234567890 ,ADDRESS为 E0:15:22:42:28
sudo eth0 down
sudo ra0 down
sudo killall wpa_supplicant
sudo ra0 up
sudo iwconfig
1:如果Encryption 职位on
sudo iwconfig ra0 key open
sudo iwconfig ra0 key s:1234567890
sudo iwconfig ra0 ap E0:15:22:42:28
sudo iwconfig ra0 rate auto
sudo dhclient ra0
2:如果Encryption 职位off
sudo iwconfig ra0 key off
sudo iwconfig ra0 ap E0:15:22:42:28
sudo iwconfig ra0 rate auto
sudo dhclient ra0
=========================================================================================
假设:如果WPA Personal 加密的无线网络(名称为test3),密码为1234567890 ,ADDRESS
需要将:
network={
ssid=test3
proto=WPA
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
psk=1234567890
}
写入/ect/wpa_supplicant.conf文件中,这个文件原来在/etc下是不存在的
sudo wpa_supplicant -Bw -D wext -i ra0 -c /etc/wpa_supplicant.conf
或者低版本的wpasupplicant工具使用这个命令:
sudo wpa_supplicant -B -D wext -i ra0 -c /etc/wpa_supplicant.conf
sudo dhclient ra0
*********************************************
由于需求原因,需要在matchbox里安装resolvconf:
这就产生一个问题,如果指定静态IP,/etc/resolv.conf的内容会变成
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#
然后修改/etc/resolv.conf:
nameserver 192.168.200.240
nameserver 192.168.200.234
重启电脑以后还是恢复成:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#
下边的方法是参照:http://ubuntuforums.org/archive/index.php/t-6704.html
原文给出的:
I have a nice bodgy solution which seems to stick

The file /etc/resolvconf/resolv.conf.d/base contains entries which will
always be added, regardless of what resolv.conf also adds. It's empty
by default. If you edit it:
sudo gedit /etc/resolvconf/resolv.conf.d/base
And add lines for your nameserver(s):
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
Then when resolvconf runs on startup, it will produce a resolv.conf file something like this:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
nameserver 127.0.0.1
nameserver yyy.yyy.yyy.yyy
...and that works.
如果没有装resolvconf工具的需求的话,直接把resolvconf工具给卸载了,修改/etc/resolv.conf即可
1、从PPA更新network-manager
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BC8EBFE8
在/etc/apt/sources.list最后加上
deb http://ppa.launchpad.net/network-manager/trunk/ubuntu karmic main
deb-src http://ppa.launchpad.net/network-manager/trunk/ubuntu karmic main
sudo aptitude update
sudo aptitude safe-upgrade
2、解决pppoeconf和network-manager冲突
更改/etc/NetworkManager/nm-system-settings.conf中的managed=true
更改/etc/network/interfaces,只保留
auto lo
iface lo inet loopback
删除/etc/resolv.conf
然后sudo /etc/init.d/network-manager restart
如果面板没有nm图标,ALT+F2输入nm-applet,并添加自启动(我的安装时没有添加)
3、右击NM图标,编辑链接,切换到DSL,新建,输入用户名和密码。
etc/network/interfaces
打开后里面可设置DHCP或手动设置静态ip。前面auto eth0,让网卡开机自动挂载.
1.
编辑文件/etc/network/interfaces:
sudo vi /etc/network/interfaces
并用下面的行来替换有关eth0的行:
# The primary network interface - use DHCP to find our address
auto eth0
iface eth0 inet dhcp
用下面的命令使网络设置生效:
sudo /etc/init.d/networking restart
也可以在命令行下直接输入下面的命令来获取地址
sudo dhclient eth0
2. 为网卡配置静态IP地址
编辑文件/etc/network/interfaces:
sudo vi /etc/network/interfaces
并用下面的行来替换有关eth0的行:# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.3.90
gateway 192.168.3.1
netmask 255.255.255.0
#network 192.168.3.0
#broadcast 192.168.3.255
将上面的ip地址等信息换成你自己就可以了.用下面的命令使网络设置生效:
sudo /etc/init.d/networking restart
3. 设定第二个IP地址(虚拟IP地址)
编辑文件/etc/network/interfaces:
sudo vi /etc/network/interfaces
在该文件中添加如下的行:
auto eth0:1
iface eth0:1 inet static
address 192.168.1.60
netmask 255.255.255.0
network x.x.x.x
broadcast x.x.x.x
gateway x.x.x.x
根据你的情况填上所有诸如address,netmask,network,broadcast和gateways等信息.
用下面的命令使网络设置生效:
sudo /etc/init.d/networking restart
4. 设置主机名称(hostname)
使用下面的命令来查看当前主机的主机名称:
sudo /bin/hostname
使用下面的命令来设置当前主机的主机名称:
sudo /bin/hostname newname
系统启动时,它会从/etc/hostname来读取主机的名称.
关于设置主机名称的更多信息,请访问这里
5. 配置DNS
首先,你可以在/etc/hosts中加入一些主机名称和这些主机名称对应的IP地址,这是简单使用本机的静态查询.
要访问DNS 服务器来进行查询,需要设置/etc/resolv.conf文件.
假设DNS服务器的IP地址是192.168.3.2, 那么/etc/resolv.conf文件的内容应为:
search test.com
nameserver 192.168.3.2