ABOUT ME

네트워크 개발자

Today
Yesterday
Total
  • [3] lxc 컨테이너 만들어보기
    개발공부/openwrt 2024. 7. 19. 18:26

    make menu 체크항목

    1. kmodveth (커널모듈 =>네트워크 서포트)
    2. lxc 전부 다 체크
    3. usb to ethernet 되도록 설정 (네트워크 사용)
    4. ikconfig(커널모듈, 아덜모듈)
    5. 유틸리티에서 gnupg cgroupfs-mount cgroup-tools

    구워줍니다[make -j$(nproc)]

     


    여기 부분 make menuconfig 잘 설정해 주셨으면 skip해도 lxc컨테이너 문제없이 만들수 있어

    luci => wan설정해서 인터넷 연결

    vi ./etc/opkg/distfeeds.conf 로 밑 라인에

    src/gz openwrt_test https://mirror-03.infra.openwrt.org/releases/packages-23.05/aarch64_cortex-a72/packages/

    넣어줍니다


     

    lxc-create -t download -n my-openwrt -- --dist openwrt --release 22.03 --arch arm64

    (23.05버전은 meta tarball 오류가 있습니다. 22.03으로 다운그레이드 해주자)

     

    srv/lxc/my-openwrt 안에있는 config파일 수정해주자

    config 파일

    # Uncomment the following line to support nesting containers:
    #lxc.include = /usr/share/lxc/config/nesting.conf
    # (Be aware this has security implications)
    
    # Setup the LXC devices in /dev/lxc/
    lxc.tty.dir = lxc
    
    # Allow for 1024 pseudo terminals
    lxc.pty.max = 1024
    
    # Setup 4 tty devices
    lxc.tty.max = 4
    
    # Drop some harmful capabilities
    lxc.cap.keep = chown ipc_lock ipc_owner kill net_admin net_bind_service net_raw sys_admin
    
    # Ensure hostname is changed on clone
    lxc.hook.clone = /usr/share/lxc/hooks/clonehostname
    
    lxc.autodev = 1
    
    ### handle mounts (OpenWrt way)
    lxc.mount.entry = sysfs sys sysfs rw,nodev,nosuid,noexec,noatime 0 0
    lxc.mount.entry = tmpfs sys/fs/cgroup tmpfs rw,nosuid,nodev,create=dir 0 0
    lxc.mount.entry = proc proc proc rw,nodev,nosuid,noexec,noatime 0 0
    lxc.rootfs.options = rw,noatime 0 0
    
    ### root, init, hostname
    lxc.rootfs.path = dir:/srv/lxc/my-openwrt/rootfs
    lxc.init.cmd = /sbin/init
    lxc.uts.name = openwrt
    
    
    # Network configuration
    lxc.net.0.type = veth
    lxc.net.0.link = br-lan
    lxc.net.0.flags = up
    lxc.net.0.hwaddr = 00:16:3e:aa:b0:02
    lxc.net.0.name = eth1
    lxc.net.0.ipv4.address = 192.168.1.200/24
    lxc.net.0.ipv4.gateway = 192.168.1.1

    lxc-start -F -n my-openwrt

    (-F옵션은 디버깅용, 제외해도 상관없다)

     

    sudo lxc-attach -n my-openwrt

     

Designed by Tistory.