侧边栏壁纸
  • 累计撰写 64 篇文章
  • 累计创建 46 个标签
  • 累计收到 94 条评论

目 录CONTENT

文章目录

debian 11 设置静态IP

草莓牛奶
2022-10-05 / 0 评论 / 0 点赞 / 877 阅读 / 250 字 / 正在检测是否收录...
温馨提示:
「博客文章out of date 会及时更新,无特殊说明仍然有效,欢迎指正内容中的错误」

一、修改接口静态IP

查看/etc/network/interfaces配置

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface 
allow-hotplug ens18
iface ens18 inet dhcp
	
# This is an autoconfigured IPv6 interface
iface ens18 inet6 auto

修改默认的接口ens18的IPV4的dhcp

# The primary network interface 
allow-hotplug ens18
#static表示使用固定ip,dhcp表述使用动态ip
iface ens18 inet static
 #设置ip地址
 address 192.168.X.XXX
 #设置子网掩码
 netmask 255.255.255.0
 #设置网关
 getway 192.168.X.1
 #设置网段
 network 192.168.X.0
 #设置广播地址
 broadcast 192.168.X.255
 #设置首选dns
 dns-nameservers 192.168.X.1

二、重启网络

 sudo systemctl restart NetworkManager.service

如果重启后无法ping通网络,可以尝试在/etc/network/interfaces最后加入后,重启

up ip route add  default via 192.168.X.1

如果无法进行DNS解析,需要手动配置/etc/resolv.conf

#设置dns
nameserver 192.168.X.1
0

评论区