sudo gedit /etc/network/interfaces
编辑文件:
auto lo #开机自动激活
iface lo inet loopback #配置lo回环接口
mapping hotplug
script grep
map eth0 eth0
auto eth0 #开机自动激活eth0接口
iface eth0 inet static #接口eth0的静态配置
address 192.168.10.237 #IP地址
netmask 255.255.255.0 #子网掩码
network 192.168.10.0 #网络地址
gateway 192.168.10.1 #网关
broadcast 192.168.10.255 #广播地址
dns-nameservers 202.96.134.133 #DNS解析服务器IP地址
auto eth0:1 #eth0 接口配置第2个IP地址
iface eth0:1 inet static
address 192.168.1.111
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 202.96.134.133
auto wlan0 #开机自动激活无线网卡
iface wlan0 inet dhcp #自动配置IP
保存,退出。
执行:sudo /etc/init.d/networking restart
* Running /etc/init.d/networking restart is deprecated because it may not enable again some interfaces
* Reconfiguring network interfaces... [ OK ]
检测结果:
zsg@zsg-Vostro-1014:~$ ifconfig -a
eth0 Link encap:以太网 硬件地址 xx:xx:xx:xx:xx:xx
inet 地址:192.168.10.237 广播:192.168.10.255 掩码:255.255.255.0
inet6 地址: xxxx::xxxx:xfff:xxxx:xxxx/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
接收数据包:5338 错误:0 丢弃:14 过载:0 帧数:0
发送数据包:1668 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:1530196 (1.5 MB) 发送字节:300596 (300.5 KB)
中断:45 基本地址:0xe000
eth0:1 Link encap:以太网 硬件地址 xx:xx:xx:xx:xx:xx
inet 地址:192.168.1.111 广播:192.168.1.255 掩码:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 跃点数:1
中断:45 基本地址:0xe000
lo Link encap:本地环回
inet 地址:127.0.0.1 掩码:255.0.0.0
inet6 地址: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 跃点数:1
接收数据包:12 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:12 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:0
接收字节:720 (720.0 B) 发送字节:720 (720.0 B)
wlan0 Link encap:以太网 硬件地址 xx:xx:xx:xx:xx:xx
BROADCAST MULTICAST MTU:1500 跃点数:1
接收数据包:0 错误:0 丢弃:0 过载:0 帧数:0
发送数据包:0 错误:0 丢弃:0 过载:0 载波:0
碰撞:0 发送队列长度:1000
接收字节:0 (0.0 B) 发送字节:0 (0.0 B)