ubuntu开机启动网络配置 您所在的位置:网站首页 ubuntu设置eth0 ubuntu开机启动网络配置

ubuntu开机启动网络配置

2023-07-26 12:55| 来源: 网络整理| 查看: 265

欢迎淘宝搜索飞灵科技,我司相关新产品陆续上线。

手头的开发板有两个网口,网口eth0做IEEE 1588时钟同步,eth1做管理网口。所以期望对这两个网口的开机启动配置是,

eth0只要up起来,不用配置IPeth1动态获取IP 在这里插入图片描述

可以使用systemd-networkd或者netplan。

systemd-networkd

编辑配置文件 使用帮助可参考:http://manpages.ubuntu.com/manpages/bionic/man5/systemd.network.5.html

root@TSync:~# cat /etc/systemd/network/50-static.network [Match] Name=eth0 root@TSync:~# cat /etc/systemd/network/80-dhcp.network [Match] Name=eth1 [Network] DHCP=yes

开机使能service

root@TSync:~# systemctl enable systemd-networkd.service netplan

当前开发板的ubuntu版本是18.04.5 LTS,我们使用netplan配置开机启动的网络配置。在安装netplan之前,因为觉得默认的ubuntu软件源下载速度太慢,所以提前替换成清华的ubuntu软件源。可以参考之前的文章“国内ubuntu软件源”。 安装netplan

root@TSync:~# apt install netplan.io

添加配置文件 更多配置文件的写法可以参考官方文档: https://netplan.io/examples/

root@TSync:~# cat /etc/netplan/0001-eth0-eth1.yaml network: version: 2 renderer: networkd ethernets: eth1: dhcp4: true eth0: addresses: - 0.0.0.0/24 重启测试 root@TSync:~# ifconfig eth0: flags=4099 mtu 1500 ether 0a:7c:9b:05:dc:c8 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth1: flags=4163 mtu 1500 inet 192.168.31.100 netmask 255.255.255.0 broadcast 192.168.31.255 inet6 fe80::44d5:2dff:fef4:2f84 prefixlen 64 scopeid 0x20 ether 46:d5:2d:f4:2f:84 txqueuelen 1000 (Ethernet) RX packets 12 bytes 1806 (1.8 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 17 bytes 1797 (1.7 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 1000 (Local Loopback) RX packets 4 bytes 348 (348.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4 bytes 348 (348.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有