当前位置: 首页 > news >正文

busybox:启动阶段的静态 IP 配置过程

文章目录

  • 1. 前言
  • 2. 启动阶段 busybox 配置静态 IP 过程

1. 前言

限于作者能力水平,本文可能存在谬误,因此而给读者带来的损失,作者不做任何承诺。

2. 启动阶段 busybox 配置静态 IP 过程

编辑 /etc/network/interfaces 文件内容如下:

auto lo
iface lo inet loopbackauto eth0
iface eth0 inet static
address 192.168.1.188
netmask 255.255.255.0
gateway 192.168.1.1

启动时用命令 /sbin/ifup eth0 配置网络,该命令调用 busybox/networking/ifupdown.c 中的函数 ifupdown_main() 解析 /etc/network/interfaces 对网络进行配置:

/* busybox/networking/ifupdown.c */ifupdown_main()...static_up()static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec)
{int result;
# if ENABLE_FEATURE_IFUPDOWN_IPresult = execute("ip addr add %address%/%bnmask%[[ broadcast %broadcast%]] ""dev %iface%[[ peer %pointopoint%]][[ label %label%]]", ifd, exec);result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec);result += execute("[[ip route add default via %gateway% dev %iface%[[ metric %metric%]]]]", ifd, exec);return ((result == 3) ? 3 : 0);
# else/* ifconfig said to set iface up before it processes hw %hwaddress%,* which then of course fails. Thus we run two separate ifconfig */result = execute("ifconfig %iface%[[ hw %hwaddress%]][[ media %media%]][[ mtu %mtu%]] up",ifd, exec);result += execute("ifconfig %iface% %address% netmask %netmask%""[[ broadcast %broadcast%]][[ pointopoint %pointopoint%]]",ifd, exec);result += execute("[[route add default gw %gateway%[[ metric %metric%]] %iface%]]", ifd, exec);return ((result == 3) ? 3 : 0);
# endif
}
http://www.dtcms.com/a/596321.html

相关文章:

  • k8s 中遇到Calico CrashLoopBackOff 的解决方法
  • zookeeper单机版安装
  • 【Excel导入】读取WPS格式嵌入单元格内的图片
  • 福清建设银行网站网红营销的作用
  • 34节点配电网牛顿-拉夫逊潮流计算 + 分布式电源(DG)多场景分析的 MATLAB
  • 分布式专题——53 ElasticSearch高可用集群架构实战
  • 电子商务网站建设与设计网站常州建设
  • 学习编程好么 | 编程的好处与学习路径分析
  • 从中间件的历史来看移动App开发的未来
  • Faster-Whisper:更快更好的开源Asr模型
  • ubuntu部署whisper+speaker_large+qwen【gradio界面版】
  • 阿里云通过中国信通院首批安全可信中间件评估
  • 正点原子【第四期】Linux之驱动开发学习笔记-12.1 Linux 阻塞和非阻塞 IO 实验
  • 做网站fjfzwl门户wordpress主题下载
  • Elasticsearch的用法
  • LLMChain for Chat Models in LangChain
  • 【JAVA进阶】SpringBoot启动流程深度解析:从main方法到应用就绪的完整旅程
  • 昆明建设厅培训网站创意设计文案
  • 如何为虚拟机配置多渠道、可聚合、更智能的告警通知机制?
  • 分布式容器镜像自动同步系统 设计方案
  • 智联无界,术教相融:分布式医疗示教系统重构医疗教学新生态
  • 【深度学习新浪潮】三维数字孪生核心算法深度解析
  • Clustering vs Classification|聚类vs分类
  • Java-小林coding八股文(1)
  • Selenium详细教程
  • 门户网站开发介绍上海华谊集团建设有限公司网站
  • 8. Linux-riscv内存管理35-40问
  • Vue3响应式系统中,对象新增属性、数组改索引、原始值代理的问题如何解决?
  • HTTP接口和Dubbo接口区别
  • K8S中ETCD高可用机制详解