containernetworking / cni

Container Network Interface - networking for Linux containers

Home Page:https://cni.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug? :: Unable to change interface for dhcp plugin in daemon mode

dkondidatov opened this issue · comments

Hi,

We are trying to configure macvlan network with dhcp in Nomad.
We have running dchp plugin in daemon mode as systemd service on the same host machine, where we are running our containers with such cni network.

For some reason dhcp daemon using non-existing eth0 interface when it is trying to transmit dhcp request.

CNI version: 1.1.1

How it can be changed to the same interface as master from network config?

Network config:

{
  "cniVersion": "1.0.0",
  "name": "macvlan_net",
  "plugins": [
    {
      "type": "macvlan",
      "master": "ens8",
      "ipam": {
        "type": "dhcp"
      }
    },
    {
      "type": "portmap",
      "capabilities": {
        "portMappings": true
      }
    }
  ]
}

Available interfaces:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 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: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8942 qdisc fq_codel state UP group default qlen 1000
    link/ether fa:16:3e:ad:ba:92 brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.161/24 brd 192.168.100.255 scope global dynamic ens3
       valid_lft 35466sec preferred_lft 35466sec
    inet6 fe80::f816:3eff:fead:ba92/64 scope link 
       valid_lft forever preferred_lft forever
3: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc fq_codel state UP group default qlen 1000
    link/ether ba:16:3e:81:92:c3 brd ff:ff:ff:ff:ff:ff
    inet 10.94.1.13/21 brd 10.94.1..255 scope global dynamic ens4
       valid_lft 35466sec preferred_lft 35466sec
    inet6 fe80::f811:3eaf:fe85:94b3/64 scope link 
       valid_lft forever preferred_lft forever
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:a1:59:2b:b2 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
6: ens8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8942 qdisc fq_codel state UP group default qlen 1000
    link/ether fa:16:3e:7f:b5:9e brd ff:ff:ff:ff:ff:ff
    inet 192.168.210.5/24 brd 192.168.210.255 scope global ens8
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fe7f:b59e/64 scope link 
       valid_lft forever preferred_lft forever

Logs from dhcp in daemon mode after trying to use this network

Nov 11 07:46:10 traefik-dev-nomad-privilege-client-panther-0 dhcp[119457]: 2022/11/11 07:46:10 Link "eth0" down. Attempting to set up
Nov 11 07:46:10 traefik-dev-nomad-privilege-client-panther-0 dhcp[119457]: 2022/11/11 07:46:10 network is down
Nov 11 07:46:10 traefik-dev-nomad-privilege-client-panther-0 dhcp[119457]: 2022/11/11 07:46:10 retrying in 3.131274 seconds
Nov 11 07:46:23 traefik-dev-nomad-privilege-client-panther-0 dhcp[119457]: 2022/11/11 07:46:23 no DHCP packet received within 10s
Nov 11 07:46:23 traefik-dev-nomad-privilege-client-panther-0 dhcp[119457]: 2022/11/11 07:46:23 retrying in 7.313039 seconds
Nov 11 07:46:40 traefik-dev-nomad-privilege-client-panther-0 dhcp[119457]: 2022/11/11 07:46:40 no DHCP packet received within 10s

Unit configuration:

[Unit]
Description=CNI dhcp Service
Requires=network-online.target
After=network-online.target
 
[Service]
User=root
Group=root
ExecStart=/opt/cni/bin/dhcp daemon --broadcast=true
ExecReload=/bin/kill --signal HUP $MAINPID
KillMode=process
KillSignal=SIGINT
Restart=on-failure
RestartSec=2
StartLimitBurst=3
StartLimitInterval=10
 
[Install]
WantedBy=multi-user.target

I've tried to rename network interface to eth0, but dhcp daemon still can't see this network.

Nov 18 09:04:16 traefik-dev-nomad-privilege-client-panther-0 systemd[1]: Started CNI dhcp Service.
Nov 18 09:04:17 traefik-dev-nomad-privilege-client-panther-0 dhcp[46251]: 2022/11/18 09:04:17 5e43f199-892c-52cd-f1af-45c7c3e8beaa/macvlan_net/eth0: acquiring lease
Nov 18 09:04:17 traefik-dev-nomad-privilege-client-panther-0 dhcp[46251]: 2022/11/18 09:04:17 Link "eth0" down. Attempting to set up
Nov 18 09:04:17 traefik-dev-nomad-privilege-client-panther-0 dhcp[46251]: 2022/11/18 09:04:17 network is down
Nov 18 09:04:17 traefik-dev-nomad-privilege-client-panther-0 dhcp[46251]: 2022/11/18 09:04:17 retrying in 2.881018 seconds
Nov 18 09:04:30 traefik-dev-nomad-privilege-client-panther-0 dhcp[46251]: 2022/11/18 09:04:30 no DHCP packet received within 10s

What network interface did you rename? eth0 is the default name of the interface inside the container when you don't supply one via CNI_IFNAME environment variable.

Is there a dhcp server on the other side of the macvlan interface? The dhcp plugin is a dhcp client on behalf of the containers which use it as their ipam. The purpose is to use this plugin vs every container having to add their own dhcp client (e.g. dhclient) to their container image.

Hi,

I've renamed ens8 interface to eth0.

6: ens8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 8942 qdisc fq_codel state UP group default qlen 1000
    link/ether fa:16:3e:7f:b5:9e brd ff:ff:ff:ff:ff:ff
    inet 192.168.210.5/24 brd 192.168.210.255 scope global ens8
       valid_lft forever preferred_lft forever
    inet6 fe80::f816:3eff:fe7f:b59e/64 scope link 
       valid_lft forever preferred_lft forever

DHCP server in daemon mode running via Systemd unit.
DHCP server in this part of network is available for all clients in this network segment.

Should I specify CNI_IFNAME for dhcp unit on client node?