在 arm 版的 pve 中建了一个 alpine lxc 容器,发现每次重启容器后网络配置都被还原 - V2EX
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
moxuanyuan
V2EX    Linux

在 arm 版的 pve 中建了一个 alpine lxc 容器,发现每次重启容器后网络配置都被还原

  •  
  •   moxuanyuan Jul 21, 2023 2662 views
    This topic created in 1027 days ago, the information mentioned may be changed or developed.

    在一台 arm vps ( 6c16g200G ) 上装了 pve ,

    因为只有单 ip ,网络按照文档中的基于 iptables 的网络地址转换配置进行配置

    # The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug enp1s0 iface enp1s0 inet static address xxx.xxx..xxx..xxx./24 gateway xxx..xxx..xxx..xxx. # dns-* options are implemented by the resolvconf package, if installed dns-nameservers 1.0.0.1 8.8.4.4 iface enp1s0 inet6 dhcp auto vmbr0 iface vmbr0 inet static address 10.10.10.1/24 bridge-ports none bridge-stp off bridge-fd 0 post-up echo 1 > /proc/sys/net/ipv4/ip_forward post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o enp1s0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o enp1s0 -j MASQUERADE 

    然后在 pve webui 中新建一个 alpine 非特权容器,网络设置中也手动设置了 ip 和网关

    进入容器后,发现容器没网络,进一步排查发现 /etc/network/interfaces 中的配置为 iface vmbr0 inet dhcp,于是手动修改了 /etc/network/interfaces

    auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 10.10.10.100/24 gateway 10.10.10.1 

    重启网络,连网正常,但。。一单容器重启,/etc/network/interfaces 文件被还原为

    auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp 

    试过把容器删除重新建一个,也一样。。

    arm vps 安装的是 debian 11 ,pve 用的是佛西版 https://github.com/jiangcuo/Proxmox-Arm64

    4 replies    2023-07-21 22:46:50 +08:00
    allplay
        1
    allplay  
       Jul 21, 2023
    对网络不精通,看你描述估计是容器的问题。
    你对容器内的文件修改没有持久化存储,容器的卷应该映射到容器外磁盘目录里面。
    以 docker 为例: -v <source>:<destination> 来指定容器内外的卷的映射定义,这样你修改容器外的文件,就等于修改了容器内的文件。这样定义的卷不受容器重启和删除的影响。
    Proxmox 用的 LXC ,和 Docker 相似,但不完全相同,解决思路类似。按照 LXC 的命令来处理文件。
    你也可以在 Proxmox 上装 docker ,用 portainer 来管理。你的机器配置完全够。
    moxuanyuan
        2
    moxuanyuan  
    OP
       Jul 21, 2023
    @allplay #1 在容器中安装其它软件,重启是可以用的,说明文件有持久化,就是修改网络配置不行
    allplay
        3
    allplay  
       Jul 21, 2023
    @moxuanyuan 试一下卷映射呢,把/etc/network/interfaces 强行映射出来,看它还会不会发生变化
    About     Help     Advertise     Blog     API     FAQ     Solana     1200 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 32ms UTC 23:35 PVG 07:35 LAX 16:35 JFK 19:35
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86