Debian下配置网络的方法

配置网卡
修改 /etc/network/interfaces 添加如下

1
2
3
4
5
6
7
8
# #号后面是备注
auto eth0 #开机自动激活
iface eth0 inte static #静态IP
address 192.168.0.56 #本机IP
netmask 255.255.255.0 #子网掩码
gateway 192.168.0.254 #路由网关
 
#因为我是通过路由上网的,所以配置为静态IP和网关

如果是用DHCP自动获取,请在配置文件里添加如下:

1
iface eth0 inet dhcp

设置DNS

1
2
echo "nameserver 202.96.128.86" >> /etc/resolv.conf
#请设置为你当地的DNS

到这里配置好以后,重启一下网卡。

1
/etc/init.d/network restart

ZHANGCHI wechat
关注微信号进一步交流