Debian-Linux配置网卡网络方法

Debian不同于centos系统,网卡配置不是在/etc/sysconfig/network-scrip里面,而是在/etc/network/interfaces里面

1.Debian网络配置

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

复制代码
 
auto eth0 #开机自动启动
iface eth0 inet static #静态IP设置
address 192.168.0.10 #本机IP
netmask 255.255.255.0 #子网掩码
gateway 192.168.0.1 #网关
 
#这边是配置KVM虚拟机,所以配置为静态IP
复制代码

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

iface eth0 inet dhcp

设置DNS:

复制代码
echo "nameserver 202.96.128.86" >> /etc/resolv.conf
或者
cp /etc/resolv.conf /etc/resolv.conf.bak # 备份原有dns配置文件
vi /etc/resolv.conf # 编辑配置文件
nameserver 202.96.128.86 # 设置首选dns
nameserver 8.8.4.4 # 设置备用dns
复制代码

配置好重启网络命令:

指定网卡重启
ifdown eth0
ifup eth0


网络重启
/etc/init.d/networking restart
service networking restart
原文地址:https://www.cnblogs.com/saryli/p/11807223.html