AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1039735
Accepted
Francis
Francis
Asked: 2020-10-23 08:12:26 +0800 CST2020-10-23 08:12:26 +0800 CST 2020-10-23 08:12:26 +0800 CST

在 Ubuntu 20.04 上使用 clevis/tang 时如何删除分配的 dhcp ip

  • 772

我在 Ubuntu 服务器 (NBDE) 上使用 clevis/tang 解锁我的驱动器。它工作正常,但即使我的服务器配置为使用 /etc/netplan/01-netcfg.yaml 中的静态 ip,我的网络接口也会监听启动过程中的两个 dhcp ip。启动完成后如何删除它?

我使用以下命令启用了 clevis:

sudo apt install clevis clevis-systemd clevis-initramfs clevis-luks
sudo clevis luks bind -d /dev/sda3 sss '{"t": 1, "pins": {"tang": [{"url": "http://10.1.1.1:8888"},{"url": "http://10.2.2.2:8888"}]}}' 
sudo update-initramfs -u -k 'all'

重新启动我的服务器后,网络接口获得了 3 个 ips!我在 /etc/netplan 中配置的静态 ip 和两个 dhcp ip。一个 dhcp ip 被 clevis 进程使用(我在我的 tang 服务器上看到了一个踪迹)。另一个似乎是在 U 形夹过程完成后分配的。

我能够制作 clevis 来删除它使用的 dhcp ip。我注意到 at 的脚本/usr/share/initramfs-tools/scripts/local-bottom/clevis与 clevis git 存储库中的脚本不同。我iface=$(basename "$iface")在if [ -e "$iface" ]; then.

但是我仍然在我的界面上使用一个无用的 dhcp ip。当我执行时netplan apply,systemd-networkd 甚至刷新 dhcp 租约,就像您可以在以下日志提取中一样:

Oct 22 12:04:56 testserver systemd[1]: Reloading.
Oct 22 12:04:56 testserver systemd[1]: /lib/systemd/system/dbus.socket:5: ListenStream= references a path below legacy directory /var/run/, updating /var/run/dbus/system_bus_socket → /run/dbus/system_bus_socket; please update the unit file accordingly.
Oct 22 12:04:56 testserver systemd[1]: systemd-networkd-wait-online.service: Succeeded.
Oct 22 12:04:56 testserver systemd[1]: Stopped Wait for Network to be Configured.
Oct 22 12:04:56 testserver systemd[1]: Stopping Network Service...
Oct 22 12:04:57 testserver systemd[1]: systemd-networkd.service: Succeeded.
Oct 22 12:04:57 testserver systemd[1]: Stopped Network Service.
Oct 22 12:04:57 testserver systemd[1]: Condition check resulted in OpenVSwitch configuration for cleanup being skipped.
Oct 22 12:04:57 testserver systemd[1]: Starting Network Service...
Oct 22 12:04:57 testserver systemd[1]: Condition check resulted in OpenVSwitch configuration for cleanup being skipped.
Oct 22 12:04:57 testserver systemd-networkd[1711]: eno3: Gained IPv6LL
Oct 22 12:04:57 testserver systemd-networkd[1711]: Enumeration completed
Oct 22 12:04:57 testserver systemd[1]: Started Network Service.
Oct 22 12:04:57 testserver systemd-networkd[1711]: eno3: IPv6 successfully enabled
Oct 22 12:04:57 testserver systemd-networkd[1711]: eno3: DHCPv4 address 10.1.1.71/21 via 10.1.0.1

但我在 netplan 配置中根本不使用 dhcp!

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  #renderer: networkd
  ethernets:
    eno3:
      dhcp4: no
      addresses:
      - 10.1.0.99/21
      gateway4: 10.1.0.1
      nameservers:
        addresses:
        - 10.1.0.3
        - 10.1.0.33

当我启动时netplan --debug apply,我看到dhcp4配置合并后启用!?但与什么合并?可以从/run/netplan/eno3.yaml? 在该文件中,我看到启用了 dhcp 的动态网络配置。什么会生成该文件?

ubuntu ubuntu-20.04 netplan systemd-networkd
  • 1 1 个回答
  • 705 Views

1 个回答

  • Voted
  1. Best Answer
    Francis
    2020-10-27T13:02:52+08:002020-10-27T13:02:52+08:00

    似乎在 U 形夹脚本中有一个错误。编辑/usr/share/initramfs-tools/scripts/local-bottom/clevis.

    搜索:

    for iface in /sys/class/net/*; do
        if [ -e "$iface" ]; then
            ip link  set   dev "$iface" down
            ip addr  flush dev "$iface"
            ip route flush dev "$iface"
        fi
    done
    

    用。。。来代替:

    for iface in /sys/class/net/*; do
        if [ -e "$iface" ]; then
            iface=$(basename "$iface")
            ip link  set   dev "$iface" down
            ip addr  flush dev "$iface"
            ip route flush dev "$iface"
    
            if [ -f "/run/netplan/${iface}.yaml" ]; then
                rm "/run/netplan/${iface}.yaml"
            fi
        fi
    done
    

    使用以下命令重新生成 initramfs:update-initramfs -u -k 'all'然后重新启动。

    文件 /run/netplan/eno3.yaml 不见了,所有的档 dhcp 地址也从界面上消失了!

    • 0

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • ubuntu apt-get upgrade - 如何在 shell 中单击确定?

  • VirtualBox 上 Ubuntu 的访客优化技巧 [关闭]

  • 外部硬盘上的 virtualbox 虚拟硬盘驱动器(Vista 主机上的 ubuntu 客户机)

  • 如何在 Ubuntu 上挂载 LVM 分区?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve