-
Notifications
You must be signed in to change notification settings - Fork 7
/
docker-compose.yml
29 lines (29 loc) · 1.27 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
services:
openwrt:
image: 14790897/openwrt:x86_64
container_name: openwrt
restart: always
# privileged: true
cap_add:
- NET_ADMIN # 增加 NET_ADMIN 权限
- NET_RAW
networks:
macvlan_net:
command: /sbin/init
# command: /bin/sh -c "echo 'MY_IP is ${MY_IP}' && /sbin/init && sed -i \"s/option ipaddr '192.168.0.188'/option ipaddr '192.168.0.178'/\" /etc/config/network && /etc/init.d/network restart"
networks:
macvlan_net:
driver: macvlan
driver_opts:
parent: enp1s0 # 宿主机的网卡名称,需要使用ip link show 手动查询,保持一致
ipam:
config:
- subnet: 192.168.0.0/24 # 定义容器使用的子网,需要和当前网络一致
gateway: 192.168.0.1 # 定义网关,需要和当前网络一致
# ip link add macvlan0 link enp1s0 type macvlan mode bridge # 注意重启后不保留
# ip addr add 192.168.0.198/24 dev macvlan0 # 分配在与容器相同子网内的 IP
# ip link set macvlan0 up
# ip route add 192.168.0.188 dev macvlan0
# ip route del default via 192.168.0.188 dev enp1s0 # 删除默认路由
# ip route add default via 192.168.0.188 dev macvlan0 # 添加macvlan0默认路由 172.24.66.92
# 使用这个不需要开启网卡混杂模式 ip link set dev enp1s0 promisc on