https://github.com/maxsans/container-netif-binder
Bind a physical network interface to a container (e.g. Docker) and configure it directly from the host. Includes allocation and recovery scripts.
https://github.com/maxsans/container-netif-binder
bash container docker linux netns networking physical-interface scripts
Last synced: about 1 month ago
JSON representation
Bind a physical network interface to a container (e.g. Docker) and configure it directly from the host. Includes allocation and recovery scripts.
- Host: GitHub
- URL: https://github.com/maxsans/container-netif-binder
- Owner: maxsans
- License: mit
- Created: 2025-06-27T09:13:28.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-27T09:23:49.000Z (12 months ago)
- Last Synced: 2025-08-03T21:40:54.453Z (10 months ago)
- Topics: bash, container, docker, linux, netns, networking, physical-interface, scripts
- Language: Shell
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# container-netif-binder
**Bind and unbind physical network interfaces to Linux containers (e.g. Docker) using native network namespaces.**
## Overview
This project provides portable Bash scripts to:
- Assign a physical interface (like `eth1`) to a container's network namespace.
- Reclaim the interface from the container back to the host.
These scripts are based on Linux network namespaces and are container runtime–agnostic (Docker, Podman, etc.).
---
## Requirements
- Linux system (with `iproute2`)
- Root privileges (`sudo`)
- Docker installed (for default usage)
---
## Files
### `scripts/assign-interface.sh`
Assign a physical network interface to a container and configure it with a static IP.
```bash
sudo ./scripts/assign-interface.sh
````
**Example:**
```bash
sudo ./scripts/assign-interface.sh mycontainer eth1 net1 192.168.1.100 24
```
---
### `scripts/reclaim-interface.sh`
Reclaim the interface from the container back to the host.
```bash
sudo ./scripts/reclaim-interface.sh
```
**Example:**
```bash
sudo ./scripts/reclaim-interface.sh mycontainer net1
```
---
## Notes
* The container must be running.
* It’s recommended to start it with `--network=none` to avoid interference from default Docker networking.
* You can use this on **any container** if you know the container’s **PID** and it exposes a Linux netns.
---
## Examples
See [`examples/usage.md`](examples/usage.md) for a full Docker setup walkthrough.
---
## 🛡 License
MIT — see [LICENSE](LICENSE)
```