惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

梦荟楼的后花园

玩转OpenClaw(Moltbot)|启用webui-梦荟楼的后花园 玩转OpenClaw(Moltbot)|重生之我用ai自动考试-梦荟楼的后花园 银河麒麟CVE-2025-6019漏洞排查和修复-梦荟楼的后花园 国产系统(kylin、uos)维护工具推荐-梦荟楼的后花园 debian常用命令、配置文件位置及配置方式-梦荟楼的后花园 华为防火墙多wan口指定接口进行dns透明代理-梦荟楼的后花园 华为防火墙光电互斥口切换模式-梦荟楼的后花园 天融信防火墙设置双向地址转换-梦荟楼的后花园 1panel添加群晖webdav作为备份账号-梦荟楼的后花园 Windows映射文件夹-梦荟楼的后花园 linux下使用硬盘哨兵查看raid下硬盘健康状态-梦荟楼的后花园 Windows命令查看文件的MD5/SHA1/SHA256-梦荟楼的后花园 雷池最佳实践-梦荟楼的后花园 matomo设置使用cdn获取真实客户端IP-梦荟楼的后花园 Linux硬盘io测试-梦荟楼的后花园 雷池专业版4.3.0测评💦-梦荟楼的后花园 长亭新春礼盒开箱-梦荟楼的后花园 盈高准入加密U盘或移动硬盘时一直提示正在等待Windows加载系统盘符-梦荟楼的后花园 华为交换机解决设备观察端口不足的问题-梦荟楼的后花园
Debian12配置静态ipv4和ipv6-梦荟楼的后花园
梦荟楼 · 2024-02-13 · via 梦荟楼的后花园

环境

系统:Debian12

网络环境:ipv4 ipv6均为静态ip

配置

编辑配置文件

配置思路:在动配置文件前先备份配置文件(在动配置文件前先备份是个良好的习惯),然后再编辑interfaces

备份和打开配置文件

备份原有配置文件配置文件

interface 配置文件复制并重命名为 interfacesbak

cp /etc/network/interfaces /etc/network/interfacesbak 
打开interfaces
vim /etc/network/interfaces

示例如图所示

image-rxzl.png

# 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


allow-hotplug eth0
iface eth0 inet static
address 192.168.1.233
netmask 255.255.255.0
gateway 192.168.1.1

iface eth0 inet6 static
address fe80:66:666:666::1FA2
netmask 64
gateway fe80:66:666:666::1

ipv4静态IP配置

iface eth0 inet static
address 192.168.1.233
netmask 255.255.255.0
gateway 192.168.1.1

将eth0设置为ipv4静态模式 iface eth0 inet static static表示使用固定ip,dhcp表述使用动态ip
将IP设置为192.168.1.233 address 192.168.1.233
将掩码设置为24位 netmask 255.255.255.0
将网关设置为192.168.1.1 gateway 192.168.1.1

ipv6静态IP配置

配置思路:先确认debian是否开启了ipv6然后再去配置静态IP, 不然就算配置了ipv6也不会生效

检查系统是否开启ipv6
确认是否加载ipv6内核
lsmod | grep ipv6

如果有类似的输出,则表示已经加载

nf_reject_ipv6         20480  1 ip6t_REJECT
nf_defrag_ipv6         24576  1 nf_conntrack
检查系统是否开启ipv6
cat /proc/sys/net/ipv6/conf/all/disable_ipv6

如果输出 0 ,则表示启用了,如果输入 1 则表示没有启用

若输出为1则需编辑配置文件 /etc/sysctl.conf 若输出为0则忽略以下内容

vim /etc/sysctl.conf

找到 net.ipv6.conf.all.disable\_ipv6 = 1 ,将1改为0即可。

重启网络和系统

systemctl restart networking.service
reboot
配置静态ipv6
iface eth0 inet6 static
address fe80:66:666:666::1FA2
netmask 64
gateway fe80:66:666:666::1

将eth0设置为ipv6静态模式 iface eth0 inet6 static static表示使用固定ip,dhcp表述使用动态ip
将IP设置为fe80:66:666:666::1FA2 address fe80:66:666:666::1FA2
将掩码设置为64位 netmask 64
将网关设置为fe80:66:666:666::1 gateway fe80:66:666:666::1

小知识

代码示例

# 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


allow-hotplug eth0
iface eth0 inet static
address 192.168.1.233
netmask 255.255.255.0
gateway 192.168.1.1

iface eth0 inet6 static
address fe80:66:666:666::1FA2
netmask 64
gateway fe80:66:666:666::1

allow-hotplugauto的区别

auto

在系统启动的时候启动网络接口,无论网络接口有无连接 (插入网线)。如果该接口配置了 DHCP,则无论有无网线,系统都会去获取 DHCP。并且如果没有插入网线,则等该接口超时后才会继续 DHCP。

allow-hotplug

只有当内核从网络接口检测到热插拔事件后才会启动该接口。如果系统开机时该接口没有插入网线,则系统不会启动该接口。系统启动后,如果插入网线,系统会自动启动该接口。