Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Network not working properly with static IP and mac #23993

Closed
fatihusta opened this issue Sep 18, 2024 · 1 comment
Closed

Multiple Network not working properly with static IP and mac #23993

fatihusta opened this issue Sep 18, 2024 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. network Networking related issue or feature

Comments

@fatihusta
Copy link

fatihusta commented Sep 18, 2024

Issue Description

Hi
I'm trying to create a container with 3 networks with static IP and MAC address.
That's not working sometimes as expected. Mac address and IP address assigning wrong order into container.

podman version
Client:       Podman Engine
Version:      5.2.2
API Version:  5.2.2
Go Version:   go1.23.1
Built:        Thu Jan  1 02:00:00 1970
OS/Arch:      linux/amd64

Steps to reproduce the issue

Steps to reproduce the issue

podman network create --subnet 10.199.0.0/24 net0
podman network create --subnet 10.199.1.0/24 net1
podman network create --subnet 10.199.2.0/24 net2

## Working
podman run -itd --name test1 --hostname test1 --network net0:ip=10.199.0.10,mac=00:00:00:00:00:01 --network net1:ip=10.199.1.10,mac=00:00:00:00:00:02 --network net2:ip=10.199.2.10,mac=00:00:00:00:00:03 ubuntu:22.04

root@podman01:~# podman exec -it test1 ip -br li
lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth2@if14        UP             00:00:00:00:00:03 <BROADCAST,MULTICAST,UP,LOWER_UP>
eth0@if16        UP             00:00:00:00:00:01 <BROADCAST,MULTICAST,UP,LOWER_UP>
eth1@if18        UP             00:00:00:00:00:02 <BROADCAST,MULTICAST,UP,LOWER_UP>

root@podman01:~# podman exec -it test1 ip -br addr
lo               UNKNOWN        127.0.0.1/8 ::1/128
eth2@if14        UP             10.199.2.10/24 fe80::200:ff:fe00:3/64
eth0@if16        UP             10.199.0.10/24 fe80::200:ff:fe00:1/64
eth1@if18        UP             10.199.1.10/24 fe80::200:ff:fe00:2/64

## Not working(Start over again)
podman container rm -f test1

podman run -itd --name test1 --hostname test1 --network net0:ip=10.199.0.10,mac=00:00:00:00:00:01 --network net1:ip=10.199.1.10,mac=00:00:00:00:00:02 --network net2:ip=10.199.2.10,mac=00:00:00:00:00:03 ubuntu:22.04

root@podman01:~# podman exec  -it test1 ip -br li
lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth0@if26        UP             00:00:00:00:00:03 <BROADCAST,MULTICAST,UP,LOWER_UP>
eth1@if28        UP             00:00:00:00:00:01 <BROADCAST,MULTICAST,UP,LOWER_UP>
eth2@if30        UP             00:00:00:00:00:02 <BROADCAST,MULTICAST,UP,LOWER_UP>

root@podman01:~# podman exec  -it test1 ip -br addr
lo               UNKNOWN        127.0.0.1/8 ::1/128
eth0@if26        UP             10.199.2.10/24 fe80::200:ff:fe00:3/64
eth1@if28        UP             10.199.0.10/24 fe80::200:ff:fe00:1/64
eth2@if30        UP             10.199.1.10/24 fe80::200:ff:fe00:2/64

# thats looks correct but assigning wrong into container.
root@podman01:~# podman inspect test1 | jq '.[0].NetworkSettings.Networks'
{
  "net0": {
    "EndpointID": "",
    "Gateway": "10.199.0.1",
    "IPAddress": "10.199.0.10",
    "IPPrefixLen": 24,
    "IPv6Gateway": "",
    "GlobalIPv6Address": "",
    "GlobalIPv6PrefixLen": 0,
    "MacAddress": "00:00:00:00:00:01",
    "NetworkID": "net0",
    "DriverOpts": null,
    "IPAMConfig": null,
    "Links": null,
    "Aliases": [
      "24a01d3e0141",
      "test1"
    ]
  },
  "net1": {
    "EndpointID": "",
    "Gateway": "10.199.1.1",
    "IPAddress": "10.199.1.10",
    "IPPrefixLen": 24,
    "IPv6Gateway": "",
    "GlobalIPv6Address": "",
    "GlobalIPv6PrefixLen": 0,
    "MacAddress": "00:00:00:00:00:02",
    "NetworkID": "net1",
    "DriverOpts": null,
    "IPAMConfig": null,
    "Links": null,
    "Aliases": [
      "24a01d3e0141",
      "test1"
    ]
  },
  "net2": {
    "EndpointID": "",
    "Gateway": "10.199.2.1",
    "IPAddress": "10.199.2.10",
    "IPPrefixLen": 24,
    "IPv6Gateway": "",
    "GlobalIPv6Address": "",
    "GlobalIPv6PrefixLen": 0,
    "MacAddress": "00:00:00:00:00:03",
    "NetworkID": "net2",
    "DriverOpts": null,
    "IPAMConfig": null,
    "Links": null,
    "Aliases": [
      "24a01d3e0141",
      "test1"
    ]
  }
}

Describe the results you received

Describe the results you received

Describe the results you expected

I expecting assign multiple interfaces into container with ordered and correct static IP and Mac address.
Or If is it possible to set the name of ethernet for the container, that resolves my problem.

podman info output

host:
  arch: amd64
  buildahVersion: 1.37.2
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - hugetlb
  - pids
  - rdma
  - misc
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon_100:2.1.12-1_amd64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.12, commit: e21e7c85b7637e622f21c57675bf1154fc8b1866'
  cpuUtilization:
    idlePercent: 99.6
    systemPercent: 0.1
    userPercent: 0.3
  cpus: 16
  databaseBackend: sqlite
  distribution:
    codename: jammy
    distribution: ubuntu
    version: "22.04"
  eventLogger: journald
  freeLocks: 2023
  hostname: traffic-vns-ci01
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.8.0-40-generic
  linkmode: dynamic
  logDriver: journald
  memFree: 31348781056
  memTotal: 33652617216
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: podman-aardvark-dns_100:1.12.2-1_amd64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.12.2
    package: podman-netavark_100:1.12.2-1_amd64
    path: /usr/libexec/podman/netavark
    version: netavark 1.12.2
  ociRuntime:
    name: runc
    package: cri-o-runc_100:1.1.14-1_amd64
    path: /usr/lib/cri-o-runc/sbin/runc
    version: |-
      runc version unknown
      spec: 1.0.2-dev
      go: go1.23.1
      libseccomp: 2.5.3
  os: linux
  pasta:
    executable: ""
    package: ""
    version: ""
  remoteSocket:
    exists: true
    path: /run/podman/podman.sock
  rootlessNetworkCmd: pasta
  security:
    apparmorEnabled: true
    capabilities: CAP_AUDIT_WRITE,CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_MKNOD,CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns_100:1.3.1-1_amd64
    version: |-
      slirp4netns version 1.3.1
      commit: unknown
      libslirp: 4.8.0
      SLIRP_CONFIG_VERSION_MAX: 5
      libseccomp: 2.5.3
  swapFree: 4115656704
  swapTotal: 4115656704
  uptime: 0h 43m 5.00s
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /usr/share/containers/storage.conf
  containerStore:
    number: 1
    paused: 0
    running: 1
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 209064443904
  graphRootUsed: 21777387520
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "true"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 2
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 5.2.2
  Built: 0
  BuiltTime: Thu Jan  1 02:00:00 1970
  GitCommit: ""
  GoVersion: go1.23.1
  Os: linux
  OsArch: linux/amd64
  Version: 5.2.2

Podman in a container

No

Privileged Or Rootless

Privileged

Upstream Latest Release

No

Additional environment details

Additional environment details

Additional information

Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting

@fatihusta fatihusta added the kind/bug Categorizes issue or PR as related to a bug. label Sep 18, 2024
@Luap99 Luap99 added the network Networking related issue or feature label Sep 18, 2024
@Luap99
Copy link
Member

Luap99 commented Sep 18, 2024

The ip and mac address are assigned correctly to the same interface in both cases.
There is guarantee that the order of the cli is doing anything in terms of interface creation in the netns (and it cannot because it is stored in maps and looping over the maps means undefined ordering) see #12850

@Luap99 Luap99 closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2024
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Dec 18, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. network Networking related issue or feature
Projects
None yet
Development

No branches or pull requests

2 participants