11.2. Running the DHCP plugin for Netavark using systemd


Prerequisites

  • The container-tools meta-package is installed.

Procedure

  1. Enable the DHCP proxy by using the systemd socket:

    systemctl enable --now netavark-dhcp-proxy.socket
    Created symlink /etc/systemd/system/sockets.target.wants/netavark-dhcp-proxy.socket  /usr/lib/systemd/system/netavark-dhcp-proxy.socket.
  2. Optional: Display the socket unit file:

    # cat /usr/lib/systemd/system/netavark-dhcp-proxy.socket
    [Unit]
    Description=Netavark DHCP proxy socket
    
    [Socket]
    ListenStream=%t/podman/nv-proxy.sock
    SocketMode=0660
    
    [Install]
    WantedBy=sockets.target
  3. Create a macvlan network and specify your host interface with it. Typically, it is your external interface:

    # podman network create -d macvlan --interface-name <LAN_INTERFACE> mv1
    mv1
  4. Run the container by using newly created network:

    # podman run --rm --network mv1 -d --name test alpine top
    894ae3b6b1081aca2a5d90a9855568eaa533c08a174874be59569d4656f9bc45

Verification

  1. Confirm the container has an IP on your local subnet:

    # podman exec test ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
        link/ether 5a:30:72:bf:13:76 brd ff:ff:ff:ff:ff:ff
        inet 192.168.188.36/24 brd 192.168.188.255 scope global eth0
           valid_lft forever preferred_lft forever
        inet6 fe80::5830:72ff:febf:1376/64 scope link
           valid_lft forever preferred_lft forever
  2. Inspect the container to verify it uses correct IP addresses:

    # podman container inspect test --format {{.NetworkSettings.Networks.mv1.IPAddress}}
    192.168.188.36
注意

When attempting to connect to this IP address, ensure the connection is made from a different host. Connections from the same host are not supported when using macvlan networking.

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2026 Red Hat
返回顶部