Programming custom mega2560 board over LAN

Hi,
I have a custom board with mega2560 chip and W5500 ethernet controller.
There is no USB port and I use any bootloader.
I currently program it through ICSP.

I tried ArduinoOTA library but whenever I try to upload the code, the IDE asks for password, then gives this error Resetting the board Failed to reset the board, upload failed

Has anyone here successfully programmed any mega board over the air?

of course it works. it is not a joke.
but you must have the Optiboot bootloader from MegaCore, which supports bootloading from internal flash memory for the ArduinoOTA library.

I did try the bootloader mentioned in the link as modified optiboot. But I am still getting the same error.
I will try again and state the exact steps that i am following

https://github.com/jandrassy/ArduinoOTA#arduinoota-tool-returns-failed-to-reset-the-board-upload-failed

These are the steps that I followed using ICSP programming with an Arduino board programmed as ISP :

  1. Added the boards from my_boards-master folder and selected Arduino Mega 2560 (Optiboot)
  2. Burnt the bootloader.
  3. Uploaded the OTEthernet code. Now at this point, as I am uploading the code through ICSP lines, in my understanding it would overwrite the bootloader.
  4. Try to upload next code through the Network port option that is visible in Tools->Port
  5. Getting this error `Resetting the board

Failed to reset the board, upload failed`

EDIT: I just saw the new reply. I will try it now

change the ICSP upload to upload hex with bootloader