Sign inSign up

198512qq/openwrt

By 198512qq

Updated about 1 month ago

openwrt:v25.12

Image
0

129

198512qq/openwrt repository overview

基于kiddin9 OpenWrt固件定制,自用优化版本,只安装了OpenClash, 用户名密码:root

单网卡

services:
  openwrt:
    image: 198512qq/openwrt:v25.12f
    container_name: openwrt
    restart: no                 # 👈  启动模式
    stop_grace_period: 1s       # 👈  1秒停止 
    
    privileged: true            # 👈 开启特权(路由系统必需)
    
    environment:
      - LAN_IP=192.168.0.3       # OpenWrt 网关 IP
      - LAN_MASK=255.255.255.0  # 子网掩码
      - ROOT_PASSWORD=root

    volumes:                    # 👈 挂载持久化目录
      - /vol1/1000/docker/openwrt/root:/host_root
      - /vol1/1000/docker/openwrt/etc:/host_etc
      - /vol1/1000/docker/openwrt/usr:/host_usr

    mac_address: a0:03:03:03:03:03  # 👈 固定 MAC 地址

    networks:
      macvlan_ipv6:
        ipv4_address: 192.168.0.3  # 👈 容器固定 IP 地址

networks:
  macvlan_ipv6:
    external: true              # 👈 声明为外部已存在的网络

多网卡

services:
  openwrt:
    image: 198512qq/openwrt:v25.12
    container_name: openwrt
    restart: always             
    stop_grace_period: 1s  
    
    privileged: true            # 👈 开启特权模式

    environment:
      - LAN_IP=192.168.0.100     # OpenWrt LAN 口 IP
      - LAN_MASK=255.255.255.0  # 子网掩码
      - ROOT_PASSWORD=root       

    volumes: 
      - ./openwrt/root:/host_root
      - ./openwrt/etc:/host_etc
      - ./openwrt/usr:/host_usr

    networks:
      macvlan_lan:
        ipv4_address: 192.168.0.100
        mac_address: a0:a1:a2:a3:a4:01
      macvlan_wan:
        ipv4_address: 192.168.1.100
        mac_address: a0:a1:a2:a3:a4:02

networks:
  macvlan_lan:
    external: true              # 外部创建的 LAN Macvlan 网络
  macvlan_wan:
    external: true              # 外部创建的 WAN Macvlan 网络

macvlan模式实现容器与宿主机网络互通(不和宿主机互通可忽略)

1. 清理宿主机现存macvlan虚拟接口(非必要,按需执行)
ip -br link show type macvlan | awk '{print $1}' | xargs -r ip link del

2. 创建宿主机macvlan虚拟接口、配置IP并启用网卡 
   (名字macvlan-666,192.168.0.254为宿主机的虚拟ip用来和容器互通,根据自身实际情况修改)
   (enp1s0-ovs网卡名 按实际名称进行修改 查看命令:ip -br link show)

ip link add host-macvlan link enp1s0-ovs type macvlan mode bridge
ip addr add 192.168.0.254/24 dev macvlan-666
ip link set macvlan-666 up

3. 添加需要和宿主机互通的容器ip
ip route add 192.168.0.100 dev macvlan-666
# ip route add 192.168.0.101 dev macvlan-666
# ip route add xxx.xxx.xxx.xxx dev macvlan-666

4. 查看系统内核层macvlan虚拟接口
ip -br link show type macvlan

4.1 查看接口详细参数
ip link show type macvlan

5. 查看Docker托管的macvlan网络
docker network ls | grep macvlan

已知问题 : 飞牛面板中 删除,重建会导致飞牛重启

Tag summary

Content type

Image

Digest

sha256:c62ad779f

Size

88.4 MB

Last updated

about 1 month ago

docker pull 198512qq/openwrt:v25.12f