Debian-Linux配置网卡网络方法

2年前 (2022) 程序员胖胖胖虎阿
245 0 0

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

1.Debian网络配置

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

Debian-Linux配置网卡网络方法
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
Debian-Linux配置网卡网络方法

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

iface eth0 inet dhcp

设置DNS:

Debian-Linux配置网卡网络方法
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
Debian-Linux配置网卡网络方法

配置好重启网络命令:

指定网卡重启
ifdown eth0
ifup eth0


网络重启
/etc/init.d/networking restart
service networking restart

版权声明:程序员胖胖胖虎阿 发表于 2022年9月4日 上午2:16。
转载请注明:Debian-Linux配置网卡网络方法 | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...