[PR #751] [CLOSED] Proposal: Add zero-configuration networking support via zeroconf #72606

Closed
opened 2026-05-05 04:09:02 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/751
Author: @ericrallen
Created: 10/10/2023
Status: Closed

Base: mainHead: feature/network-discovery


📝 Commits (1)

  • c188699 feat: add network discovery via zeroconf

📊 Changes

4 files changed (+78 additions, -1 deletions)

View changed files

📝 app/src/index.ts (+15 -0)
📝 cmd/cmd.go (+35 -0)
📝 go.mod (+6 -1)
📝 go.sum (+22 -0)

📄 Description

This proposal allows the Ollama service to be made discoverable via zero configuration networking across the user's local network via Bonjour/Zeroconf/Avahi aka Multicast DNS (mDNS) using the zeroconf Go libraryso that other clients can connect to and use it without needing to know the host's IP address.

This opens up many different applications for consuming Ollama models served by other network devices.

My particular use case is to add support for Network Discoverable Ollama models to an Obsidian Plugin that I maintain so that users won't have to configure IP addresses in Obsidian or update them if/when IP addresses on their local network change (and also won't have to get into configuring a static IP for the device that is serving their local models).

Note: Network discovery is entirely opt-in via the OLLAMA_DISCOVERY environment variable flag being set to ENABLED and will automatically update the OLLAMA_HOST to 0.0.0.0 (the demo GIF was recorded with an earlier iteration of this PR that also required the user to manually set the host IP).

Demo

Ollama-Network-Discovery-Demo

Note: To test this functionality, I created a simple Node.js script on another machine on my network and had it use the bonjour package to search for a service with the name OllamaProvider. It gets the IP address and port associated with that service and then makes requests to it. I only showed the IP address at the beginning of the GIF to emphasize that the requests are coming from a different machine.

It also adds a menu entry with the service name if Network Discovery has been enabled.

Screen Shot 2023-10-10 at 5 09 30 PM

Instructions for Testing

  1. Checkout this PR: gh pr checkout https://github.com/jmorganca/ollama/pull/751
  2. Generate: go generate ./...
  3. Build: go build .
  4. Build and run the App:
    1. cd ./app
    2. npm install
    3. OLLAMA_DISCOVERY=ENABLED npm start
  5. Search for and connect to your Network Service (I've provided an example discovery script below)

Network Discovery Script

// you'll need to `npm install bonjour` first
// it's recommended to put this in a subdirectory
// and run `npm init` before installing packages
const bonjour = require("bonjour")();

// this demo script can be run via node to find
// and connect to a Network Service with the name
//defined in OLLAMA_SERVICE_NAME
const OLLAMA_SERVICE_NAME = 'OllamaProvider'

// iterate through services
bonjour.find({}, (service) => {
  if (service.name === OLLAMA_SERVICE_NAME) {
    const address = service.addresses[0];
    const port = service.port;

    const baseUrl = new URL(address);

    baseUrl.port = port;

    const modelsUrl = new URL("/api/tags", baseUrl);

    // get available models
    fetch(modelsUrl)
      .then(async (response) => await response.json())
      .then((response) => {
        console.log(response);
      })
      .catch((error) => {
        console.error(error);
      })
  }
});

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/751 **Author:** [@ericrallen](https://github.com/ericrallen) **Created:** 10/10/2023 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feature/network-discovery` --- ### 📝 Commits (1) - [`c188699`](https://github.com/ollama/ollama/commit/c188699884ade3ca1df91e416d7d618ba7ff556f) feat: add network discovery via zeroconf ### 📊 Changes **4 files changed** (+78 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `app/src/index.ts` (+15 -0) 📝 `cmd/cmd.go` (+35 -0) 📝 `go.mod` (+6 -1) 📝 `go.sum` (+22 -0) </details> ### 📄 Description This proposal allows the Ollama service to be made discoverable via [zero configuration networking](https://en.wikipedia.org/wiki/Zero-configuration_networking) across the user's local network via Bonjour/Zeroconf/Avahi aka [Multicast DNS (mDNS)](https://en.wikipedia.org/wiki/Multicast_DNS) using the [`zeroconf` Go library](https://github.com/grandcat/zeroconf)so that other clients can connect to and use it without needing to know the host's IP address. This opens up many different applications for consuming Ollama models served by other network devices. My particular use case is to add support for Network Discoverable Ollama models to an [Obsidian Plugin that I maintain](https://github.com/InterwebAlchemy/obsidian-ai-research-assistant) so that users won't have to configure IP addresses in Obsidian or update them if/when IP addresses on their local network change (and also won't have to get into configuring a static IP for the device that is serving their local models). **Note**: Network discovery is entirely opt-in via the `OLLAMA_DISCOVERY` environment variable flag being set to `ENABLED` and will automatically update the `OLLAMA_HOST` to `0.0.0.0` (the demo GIF was recorded with an earlier iteration of this PR that also required the user to manually set the host IP). ## Demo ![Ollama-Network-Discovery-Demo](https://github.com/jmorganca/ollama/assets/1667415/5122405e-5d1e-423a-9279-1c6efcbbcd8f) **Note**: To test this functionality, I created a simple Node.js script on another machine on my network and had it use the [`bonjour`](https://www.npmjs.com/package/bonjour) package to search for a service with the name `OllamaProvider`. It gets the IP address and port associated with that service and then makes requests to it. I only showed the IP address at the beginning of the GIF to emphasize that the requests are coming from a different machine. It also adds a menu entry with the service name if Network Discovery has been enabled. ![Screen Shot 2023-10-10 at 5 09 30 PM](https://github.com/jmorganca/ollama/assets/1667415/983cccd6-370f-4ab6-b7a2-8794ed841c7b) ## Instructions for Testing 1. Checkout this PR: `gh pr checkout https://github.com/jmorganca/ollama/pull/751` 2. Generate: `go generate ./...` 3. Build: `go build .` 4. Build and run the App: 1. `cd ./app` 2. `npm install` 3. `OLLAMA_DISCOVERY=ENABLED npm start` 5. Search for and connect to your Network Service (_I've provided an example discovery script below_) ### Network Discovery Script ```js // you'll need to `npm install bonjour` first // it's recommended to put this in a subdirectory // and run `npm init` before installing packages const bonjour = require("bonjour")(); // this demo script can be run via node to find // and connect to a Network Service with the name //defined in OLLAMA_SERVICE_NAME const OLLAMA_SERVICE_NAME = 'OllamaProvider' // iterate through services bonjour.find({}, (service) => { if (service.name === OLLAMA_SERVICE_NAME) { const address = service.addresses[0]; const port = service.port; const baseUrl = new URL(address); baseUrl.port = port; const modelsUrl = new URL("/api/tags", baseUrl); // get available models fetch(modelsUrl) .then(async (response) => await response.json()) .then((response) => { console.log(response); }) .catch((error) => { console.error(error); }) } }); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 04:09:02 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#72606