Debian设置静态ip,网关,dns

Debian设置静态ip,网关,dns

香蕉
2022-10-29 / 0 评论 / 10 阅读 / 正在检测是否收录...

如果没有vim ,建议先apt install vim 安装下

1. 设置ip地址和网关

cp /etc/network/interfaces /etc/network/interfacesbak #备份原有配置文件
vim /etc/network/interfaces #编辑网网卡配置文件

  auto lo
  auto eth0  #开机自动连接网络
  iface lo inet loopback
  allow-hotplug eth0
  iface eth0 inet static   #static表示使用固定ip,dhcp表述使用动态ip
  address 192.168.21.166   #设置ip地址
  netmask 255.255.255.0  #设置子网掩码
  gateway 192.168.21.2    #设置网关

ctrl+c 退出编辑,输入 :wq 保存设置后退出。
实际ip 根据本地情况修改。

2.设置dns

cp /etc/resolv.conf /etc/resolv.confbak #备份原有dns配置文件
vim /etc/resolv.conf #编辑配置文件

  nameserver 8.8.8.8   #设置首选dns

3.重启网络

service networking restart #重启网络

0

评论 (0)

取消