Sign inSign up

ruiray/docker_gateway

By ruiray

•Updated over 3 years ago

a container can be as a lan gatway

Image
0

137

ruiray/docker_gateway repository overview

⁠usage

⁠create macvlan

You need to change 10.176.22.0/24 to your own network.

docker network create -d macvlan \
    --subnet=10.176.22.0/24 \
    --gateway=10.176.22.1 \
     -o parent=em1 \
     -o macvlan_mode=bridge macnet

⁠run container

  1. create a container
docker run --name rui -it -d --network macnet  --restart unless-stopped --privileged --ip 10.176.22.33 ruiray/docker_gateway:20230225 /bin/sh
  1. enter the container and add iptables rules.
docker exec -it rui /bin/sh
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

⁠change the network

Then you can change your gateway to 10.176.22.33.

More information can be found at https://blog.hifool.cn/posts/centos-gateway/⁠

Tag summary

Content type

Image

Digest

sha256:18bedd8ed…

Size

9.7 MB

Last updated

over 3 years ago

docker pull ruiray/docker_gateway