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自动获取,请在配置文件里添加如下:

设置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


bigood 2023年3月28日 20:09 收藏文档