samdbmg / dhcp-netboot.xyz

Docker container that acts as a ProxyDHCP server for netbooting
GNU General Public License v3.0
69 stars 18 forks source link

setup with synology and fritzbox router - wrong tftp address #3

Open tobidemski opened 2 years ago

tobidemski commented 2 years ago

Hey,

i found your project because you set up the netboot.xyz with an integrated proxy dhcp server. I tried to use your image but if i try to network boot the tftp address is always the ip of my gateway. It is possible to tell them to use the ip of the tftp server instead of gateway? Im not able to set the tftp server in my router (fritzbox) and due to my isp provider im currently not able to change this shitty configuration. I also run this configuration on a synology through portainer.

I combined your setup with this one: https://www.technorabilia.com/dockerized-netboot-xyz-on-synology-nas-and-router/ (exluded the router configuration part in the post) Im trying to avoid enabling the dhcp on the synology because its already running on my fritzbox which is running 24/7 and dont want do run two of them.

Im not sure but i think i need to edit the dnsmasq.conf to get this working. Like adding the tftp ip (in my case 192.168.1.6) at the end of each line of "dhcp-boot=..."

You copied the config from the dd-wrt part. But there is also mentioned to replace the ip with the one you define. (https://github.com/linuxserver/docker-netbootxyz#dd-wrt) (see YOURSERVERIP)

DD-WRT
Administration -> Services -> Additional DNSMasq Options Set the following lines:

dhcp-match=set:bios,60,PXEClient:Arch:00000
dhcp-boot=tag:bios,netboot.xyz.kpxe,,YOURSERVERIP
dhcp-match=set:efi32,60,PXEClient:Arch:00002
dhcp-boot=tag:efi32,netboot.xyz.efi,,YOURSERVERIP
dhcp-match=set:efi32-1,60,PXEClient:Arch:00006
dhcp-boot=tag:efi32-1,netboot.xyz.efi,,YOURSERVERIP
dhcp-match=set:efi64,60,PXEClient:Arch:00007
dhcp-boot=tag:efi64,netboot.xyz.efi,,YOURSERVERIP
dhcp-match=set:efi64-1,60,PXEClient:Arch:00008
dhcp-boot=tag:efi64-1,netboot.xyz.efi,,YOURSERVERIP
dhcp-match=set:efi64-2,60,PXEClient:Arch:00009
dhcp-boot=tag:efi64-2,netboot.xyz.efi,,YOURSERVERIP

Maybe you can take a look and have some hint to help me out.

Image of the VM image

My docker-compose file:

---
version: "2.1"
services:
  netbootxyz:
    container_name: netbootxyz
    image: samdbmg/dhcp-netboot.xyz
    environment:
      - PUID=1026
      - PGID=100
      # samdbmg configuration
      - DHCP_RANGE_START=192.168.1.20
    volumes:
      - /volume1/docker/netboot.xyz/config:/config
      - /volume1/docker/netboot.xyz/assets:/assets #optional
    networks:
      netbootxyz_network:
        ipv4_address: 192.168.1.6
    cap_add:
      - NET_ADMIN
    restart: unless-stopped
networks:
  netbootxyz_network:
    driver: macvlan
    driver_opts:
      parent: ovs_eth0
    ipam:
      config:
        - subnet: 192.168.1.0/24
          gateway: 192.168.1.1
          ip_range: 192.168.1.250/32

EDIT: Okay im not alone and the main problem is netboot.xyz. See this issue: https://github.com/netbootxyz/netboot.xyz/issues/952

hutchwilco commented 2 years ago

I have this same issue running the samdbmg/dhcp-netboot.xyz image. The DHCP proxy is not found. I understand that allowance for a proxy has now been added (following https://github.com/netbootxyz/netboot.xyz/issues/952) but there's no literature I can find about how to implement this ie, what is the environment variable/option I need to invoke or define? I assume it would be something like docker run -e --dchp-proxy=10.0.1.96 or something...

tobidemski commented 2 years ago

No i dont think you have to do something. I think his image isnt up-to-date so the fix for the proxy dhcp isnt working in his version. I spent the last day to get the netbootxyz working and all you need to do is to set this up + your proxy dhcp. If you start the pxe boot at first the netbooxyz checks for the main gateway and then asking for the proxy dhcp. Just press "p" to accept and boot over network.

image

My docker compose file:


version: "3.4" services: netbootxyz: container_name: netbootxyz image: linuxserver/netbootxyz:0.6.6 environment:

samdbmg commented 2 years ago

Sorry about this one - it's been sat on my list of stuff to do for 5 months, and I only found time to have a look at this last week! That explains why I can't reproduce the problem you were having, although curiously even prior to the proxy dhcp fix upstream it still worked on my network with various systems and Virtualbox at least.

I've re-enabled the Github Actions workflow that builds and pushes the container, which should rebuild it tomorrow morning and (hopefully 🤞 ) pick up the proxy fix.

I'm also working on https://github.com/samdbmg/dhcp-netboot.xyz/tree/feat/dnsmasq-for-tftp which switches to using dnsmasq for TFTP rather than tftpd. In the docs for the --dhcp-boot option (see https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html , search "-M, --dhcp-boot") it says

Server name and address are optional: if not provided, the name is left empty, and the address set to the address of the machine running dnsmasq. If dnsmasq is providing a TFTP service (see --enable-tftp ) then only the filename is required here to enable network booting. Which I interpreted as meaning the configuration I had was valid and you don't need those IPs, but given how small the change is, maybe it makes sense to line up with the second sentence.

I've also added a docker-compose.yml that needs a bit more testing and documentation. but I've found useful for running it on machines that already use some of the ports it needs (e.g. they're already a webserver or serving DHCP for VMs). I've learned something new about macvlan/ipvlan there, thanks @tobidemski!

Just need to test it on Hyper-V now and then tidy up the commit history mess.

hutchwilco commented 2 years ago

No i dont think you have to do something. I think his image isnt up-to-date so the fix for the proxy dhcp isnt working in his version.

Thank you for pointing this out!

My docker compose file:

version: "3.4" services: netbootxyz: container_name: netbootxyz image: linuxserver/netbootxyz:0.6.6 environment: - PUID=1000 - PGID=1000 - PORT_RANGE=30000:30010 #optional volumes: - /data/docker/netbootxyz/volume/config:/config - /data/docker/netbootxyz/volume/assets:/assets #optional ports: - 3000:3000 - 69:69/udp - 8080:80 #optional network_mode: host depends_on: - proxydhcp restart: unless-stopped proxydhcp: container_name: netbootxyz-proxydhcp restart: always image: strm/dnsmasq:latest #currently no other tag available volumes: - /data/docker/netbootxyz/volume/dnsmasq.conf:/etc/dnsmasq.conf ports: - "53:53/udp" cap_add: - NET_ADMIN network_mode: host

I have to seriously question if this is really the docker-compose.yml file you used! I'm definitely relatively new to this, but running this I found:

  1. Docker containers failed with both port mappings AND network_mode: host defined - they seem to be incompatible commands
  2. Docker containers then failed because you defined the dnsmasq.conf file in the volume mappings - should just be a directory.
  3. now I get : netbootxyz-proxydhcp exited with code 1 netbootxyz-proxydhcp | netbootxyz-proxydhcp | dnsmasq: unknown user or group: nobody

I hope this doesn't come across as ungrateful for the help - just more that I'm surprised that yaml file works for you and I'm trying to work out if there's something I missed that would make this all work.

tobidemski commented 2 years ago

Hey @hutchwilco,

you are probably right if i remember correctly of the port mapping in host mode. I run this via portainer and got no errors so far (but i think you dont need to run this in host mode). So i think if you run this in host mode, port mapping isnt an option. https://docs.docker.com/network/host/ - Just remove the port mapping if you use it with host network. Ports are exposed anyway. The second point about the dnsmasq.conf: Its a file and you need to map this. I faced issued with mapping files while they are not existing on the file system. Workaroung: Create the file on the host system first and run the docker-compose. Otherwise docker does not know which kind of type it is and tries to create a directory mapping. But maybe this work too: https://stackoverflow.com/a/54658017/10236859

So instead of: volumes:

The last 3rd point: Not sure whats happend here. I think its a follow-up error because your dnsmasq.conf isnt present where the user and group is defined for the service. (Just a guess!)

Hope this helps a bit, im not a docker expert yet and just started with the new world too.

samdbmg commented 2 years ago

Did you get this working in the end @hutchwilco? I've just merged a change to add a docker-compose.yml to the repo which might help you as a starting point if not?

I've added a note about the DHCP proxy prompt in 73bcc9c as well, and (finally!) confirmed it works on Hyper-V

hutchwilco commented 2 years ago

@samdbmg yes! sort of! I created an alpinelinux VM on proxmox, installed docker (don't try to run docker on an LXC on proxmox!) clone your repo, opened the ports as suggested, set the environment variables and quickly had the container running. I have had a VM/PXE client able to connect to the Netbootxyz instance, navigate the menus etc ok, so by that measure, successful. I'm wondering about placing ISOs locally - as in in the docker container>netboot>assets directory. Is this the right approach?

samdbmg commented 2 years ago

Best bet is probably to put the ISOs somewhere on your host, and then add another volume mount, e.g. a -v /path/to/your/isos:/assets on the command line, or another line in the volumes block if you're using docker-compose/

    volumes:
      - /path/to/your/isos:/assets

Then have a look at https://netboot.xyz/docs/docker/#local-mirror-access for how to make it pull assets locally (although if you only want to pull some distros locally, you might want to go edit the URL line in the menu itself instead because changing the live_endpoint will affect every menu. E.g.

set squash_url ${live_endpoint}/ubuntu-squash/releases/download/18.04.5-86af5ae3/filesystem.squashfs

becomes (obviously the IP may be different for you)

set squash_url http://192.168.0.250/ubuntu-squash/releases/download/18.04.5-86af5ae3/filesystem.squashfs
viritt commented 1 year ago

Hello all.

First of all appologies since I might be doing something wrong, but I'm also hitting this issue.

I am running the docker compose in portainer. It builds the netbootxyz:latest image with your dockerfile. All good, and it boots, runs and most things appear to work. When running a VMWare VM trying to PXE boot, both dhcp (router) and proxydhcp (netbootxyz) broadcast DHCP offer. The router DHCP doesn't offer bootfile nor TFTP service.

However the VM doesn't grab the proxydhcp TFTP file, and loads the regular netboot file through the Internet. So basically it tries to boot several different ways from the Router which doesn't have TFTP instead of the proxy..

Also, it appears that the next-server info appearing in the top of the menu, is the router's IP.

What can be done to solve this one ? Is this an issue with the original netboot ? I thought they added proxydhcp support...