Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -x
- set -u
- set -e
- set -o pipefail
- ETH_INT=$(ip route | grep ^default | cut -d ' ' -f 5)
- IP_GW=$(ip route | grep ^default | cut -d ' ' -f 3)
- IP_BASE=${IP_GW%.*}
- sudo ip link add bridge2 link ${ETH_INT} type macvlan mode bridge
- sudo ip link set bridge2 up
- sudo ip addr add ${IP_BASE}.192/29 dev bridge2
- docker network create -d macvlan -o parent=${ETH_INT} --gateway ${IP_GW} --subnet ${IP_BASE}.0/24 --ip-range ${IP_BASE}.198/30 bridge2
- docker run --rm --name nginx -itd --network bridge2 nginx:alpine
- sleep 2
- curl ${IP_BASE}.196
- # docker kill nginx
- # docker network rm bridge2
- # sudo ip link delete bridge2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement