Skip to content

Instantly share code, notes, and snippets.

@fritzw
Last active July 23, 2026 21:42
Show Gist options
  • Select an option

  • Save fritzw/7d981046b509a27e204d01c9bd73f37b to your computer and use it in GitHub Desktop.

Select an option

Save fritzw/7d981046b509a27e204d01c9bd73f37b to your computer and use it in GitHub Desktop.
PowerShell script to make BambuStudio discover a specific printer by IP address, even if it is not on the same subnet (see BambuStudio Issue #702)
# Send the IP address of your BambuLab printer to port 2021/udp, which BambuStudio is listens on.
#
# Ensure your PC has firewall pot 2021/udp open. This is required as the proper response would usually go to the ephemeral source port that the M-SEARCH ssdp:discover message.
# But we are are blindly sending a response directly to the BambuStudio listening service port (2021/udp).
#
# Temporary solution to BambuStudio not allowing you to manually specify the Printer IP.
#
# Author(s): gashton <https://github.com/gashton>, Fritz webering <https://github.com/fritzw>
#
param (
[string]$PRINTER_IP = "10.80.2.50" # IP address of your BambuLab Printer
)
$TARGET_IP="127.0.0.1" # IP address of your PC running BambuStudio.
$PRINTER_USN="000000000000000" # Enter your own Printer Serial Number here
$PRINTER_DEV_MODEL="3DPrinter-X1-Carbon" # Set this to your model
# PRINTER_DEV_MODEL: https://github.com/bambulab/BambuStudio/tree/master/resources/printers
# X1C : "3DPrinter-X1-Carbon"
# X1 : "3DPrinter-X1"
# X1E : "C13"
# P1P : "C11"
# P1S : "C12"
# A1 mini: "N1"
# A1 : "N2S"
$PRINTER_DEV_NAME="MY-X1C" # Here you can choose any name you want for your printer, which is shown in the slicer.
$PRINTER_DEV_SIGNAL="-44" # Good Signal (Artificial), WiFi icon in BambuStudio will appear green with full-bars.
$PRINTER_DEV_CONNECT="lan" # LAN Mode
$PRINTER_DEV_BIND="free" # Not bound to a Cloud user-account.
$remoteudpport=2021 # port to send to
$sourceudpport = 0 # SourcePort, maybe empty uses and available port
$message = "HTTP/1.1 200 OK`r`nServer: Buildroot/2018.02-rc3 UPnP/1.0 ssdpd/1.8`r`nDate: $(date)`r`nLocation: ${PRINTER_IP}`r`nST: urn:bambulab-com:device:3dprinter:1`r`nEXT:`r`nUSN: ${PRINTER_USN}`r`nCache-Control: max-age=1800`r`nDevModel.bambu.com: ${PRINTER_DEV_MODEL}`r`nDevName.bambu.com: ${PRINTER_DEV_NAME}`r`nDevSignal.bambu.com: ${PRINTER_DEV_SIGNAL}`r`nDevConnect.bambu.com: ${PRINTER_DEV_CONNECT}`r`nDevBind.bambu.com: ${PRINTER_DEV_BIND}`r`n`r`n"
$udpClient = new-Object system.Net.Sockets.Udpclient($sourceudpport)
$byteBuffer = [System.Text.Encoding]::ASCII.GetBytes($message)
$sendbytes = $udpClient.Send($byteBuffer, $byteBuffer.length, $remoteip, $remoteudpport)
if ($sendbytes -ne $byteBuffer.length) {
write-host "Mismatch bytes"
}
@rkarlsba

Copy link
Copy Markdown

Thanks a bunch for this. An elderly friend of mine, bought an A1 combo recently, and he wasn't able to connect to it by any means. I helped him out with a remote session to his PC and found that no, neither Bambu Studio nor OrcaSlicer were able to find the printer, probably because it's a common wifi network with probably a few blocks for multicast etc. I tried this script and it worked well after a couple of hours of struggling. Big thanks!

@ozgurgulsuna

Copy link
Copy Markdown

I can surely confirm this method works on even complex networks, thanks a lot.

@patrikalienus

Copy link
Copy Markdown

I made a python version of this so it's cross platform: https://gist.github.com/patrikalienus/549fcf76be41097545fe61da88e4dafe

@brummbrum

brummbrum commented Jan 22, 2025

Copy link
Copy Markdown

the script works as is, but it has a small typo. Line 36 should be
$sendbytes = $udpClient.Send($byteBuffer, $byteBuffer.length, $TARGET_IP, $remoteudpport)

Another thing worth noting for those of us who use it is this: Bambu's networking plugin still contacts the Bambu server, namely api.bambulab.com! Even AFTER Bambu Studio found the printer thanks to the script, it still requires to contact api.bambulab.com in order to make the connection. This is quite ridiculous since the connection is clearly directly over LAN with the printer and not relayed via the cloud. It does not matter that your local router can route the traffic between different local networks (VLANs, subnets, ...) - Bambu Studio requires the handshake with the Bambu cloud. If you block outgoing traffic from Bambu to the internet, the connection to the printer fails even if LAN communication is allowed.

EDIT: While it is true that Bambu Studio phones home even if you only use LAN mode it is possible to use the printer with no internet connection. I made a config mistake in the funny Windows Firewall (which oddly does not process the firewall rules in any order and therefore requires a different logic than other firewalls. In Windows firewall an ALLOW rule for outbound traffic will always be superseded by a BLOCk rule irrespective of the order. By blocking all IP addresses for outbound traffic but the local ones to the printer (residing in a different subnet/VLAN) you can print without leaving any traces whatsoever. Another (positive) side effect is that Bambu Studio does not perform the hidden update of the network plugin it would normally perform every time on startup.

@RagingRoosevelt

Copy link
Copy Markdown

If you block outgoing traffic from Bambu to the internet, the connection to the printer fails even if LAN communication is allowed

Ah, that makes everything make sense. At my work we have an X1E that I haven't been able to get working, even with this script. And of course the printer is blocked from the internet by the company firewall. I've been able to get FTPS working for uploading .gcode.3mf files, and I've been able to set up go2rtc to get a video stream working and embeddable on a webpage, but haven't been able to get a direct slicer connection for the reason you identified.

@SgtKilgore406

Copy link
Copy Markdown

In Windows, you can have this script automatically run when BambuStudio or OrcaSlicer is launched instead of manually running the script or having it trigger on a schedule.

Note that I added a Start-Sleep -Seconds 10 parameter as the first line of the script to give OrcaSlicer 10 seconds to launch before executing the script. This has helped make the auto detection of the printer in OrcaSlicer fairly seamless.

Example below:
Line 1 | Start-Sleep -Seconds 10
Line 2 | # Send the IP address of your BambuLab printer to port 2021/udp, which BambuStudio is listens on.

Follow the steps provided by Paul's answer on this super user forum post "How to start a program when another one is started" (https://superuser.com/questions/745318/how-to-start-a-program-when-another-one-is-started) to enable security audit logging on successful program starts and creating the scheduled task.

Here is the custom XML I'm using on the New Event Filter box for the scheduled task trigger:
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">
*[System[band(Keywords,9007199254740992) and (EventID=4688)]]
and
*[EventData[Data[@Name='NewProcessName'] and (Data='C:\Program Files\OrcaSlicer\orca-slicer.exe')]]
</Select>
</Query>
</QueryList>

@RonnyHunter

Copy link
Copy Markdown

Unfortunately, it seems like this got broken with the new v2.00.00.95 release of Bambu Studio.

@Android1338

Copy link
Copy Markdown

Unfortunately, it seems like this got broken with the new v2.00.00.95 release of Bambu Studio.

I can confirm that. Is it possible to resolve this issue without reverting to version 1.x?

@fritzw

fritzw commented Mar 28, 2025

Copy link
Copy Markdown
Author

Not sure. Someone would have to get out Wireshark and see what the new version does differently from this script. Unfortunately I currently don't have a Windows PC in the same network as out printer.

If someone finds out something, I would be glad to adapt the script, so that it stays helpful for future users.

@Rdiger-36

Copy link
Copy Markdown

I'm using the same strategy for my Java-based GUI program. Since version 2.0.0, it's been impossible to send valid data to Bambu Studio. I spent the whole day researching and couldn't find a way to get Bambu Studio to accept the data and connect to the printer.
Maybe it's a limitation of my knowledge, but I tried everything, from dumping packets with Wireshark and trying to recreate them, to making it work for other printers in LAN mode across different networks, subnets, and VLANs.
Hopefully, someone else will find a solution.
It still works with the latest 1.x version, but not on any other 2.x version....

@R3DPanda1

R3DPanda1 commented Apr 5, 2025

Copy link
Copy Markdown

I tried different scripts and this one worked with Bambu Studio v2.xxx
https://github.com/jonans/bsnotify/tree/main
Maybe someone can port it to PowerShell. Here is what I ran in CMD:
py bsnotify.py <PRINTER_IP> <PRINTER_SERIAL> <LOCAL_PC_IP> "<PRINTER_NAME>"

@Rdiger-36

Rdiger-36 commented Apr 5, 2025

Copy link
Copy Markdown

@R3DPanda1
Thank you for your research. I’m also looking for a solution. I tried this method, but I didn’t use it because BambuStudio disconnects my printer after 5-10 seconds. Does it work for you without any issues?

Edit:
This only happens when the printer is connected to the cloud.
I can confirm that this Works very well

@R3DPanda1

R3DPanda1 commented Apr 5, 2025

Copy link
Copy Markdown

@R3DPanda1 Thank you for your research. I’m also looking for a solution. I tried this method, but I didn’t use it because BambuStudio disconnects my printer after 5-10 seconds. Does it work for you without any issues?

Edit: This only happens when the printer is connected to the cloud. I can confirm that this Works very well

I tested it remotely at work and it works fine for me. Made a click-to-run version in PowerShell (with ChatGPT). Here’s an anonymized version. (The local PC IP is detected automatically.)
BambuConnectorV2.ps1

@bcarrington

bcarrington commented Jul 23, 2026

Copy link
Copy Markdown

For Mac users, I had Mr. Claude write something up to do the same thing and send SSDP over to my printer VLAN. It's working great, you can either run this Python script before opening Bambu Slicer, or you can set it up in LaunchAgent to have it run in the background. My printer shows up after a couple seconds in the slicer now instead of a couple minutes. It's digital duct tape but it'll do.

#!/usr/bin/env python3
"""
bambu_announce_loop.py

Repeatedly sends a fake SSDP announcement for your printer to Bambu
Studio's local listener (UDP port 2021 on localhost), so it shows up
in the device list within seconds instead of waiting on the printer's
own broadcast timer. Useful if your printer is on a different
VLAN/subnet than the machine running Bambu Studio.

Note: this only solves discovery — Bambu Studio still needs a normal
unicast network path to the printer's IP for everything after that.

Fill in the four values below, then run: python3 bambu_announce_loop.py

Model strings (see BambuStudio's resources/printers directory):
    X1C: "3DPrinter-X1-Carbon"   X1: "3DPrinter-X1"   X1E: "C13"
    P1P: "C11"   P1S: "C12"   A1 mini: "N1"   A1: "N2S"
"""

import socket
import time
from datetime import datetime, timezone

# ---- EDIT THESE THREE VALUES ----
PRINTER_IP = "192.168.1.100"        # your printer's actual IP address
PRINTER_SERIAL = "YOUR_SERIAL_HERE"  # printer's serial number
PRINTER_MODEL = "3DPrinter-X1-Carbon"  # see model strings above
PRINTER_NAME = "MyPrinter"          # any label — shown in Bambu Studio's device list
# ----------------------------------

TARGET_IP = "127.0.0.1"   # Bambu Studio always listens on localhost
TARGET_PORT = 2021
ANNOUNCE_INTERVAL_SECONDS = 5

DEV_SIGNAL = "-44"      # artificial signal strength; keeps the wifi icon full-bars
DEV_CONNECT = "lan"     # LAN mode
DEV_BIND = "free"       # not bound to a cloud account


def build_message() -> bytes:
    date_str = datetime.now(timezone.utc).strftime("%a, %d %b %Y %H:%M:%S GMT")
    msg = (
        "HTTP/1.1 200 OK\r\n"
        "Server: Buildroot/2018.02-rc3 UPnP/1.0 ssdpd/1.8\r\n"
        f"Date: {date_str}\r\n"
        f"Location: {PRINTER_IP}\r\n"
        "ST: urn:bambulab-com:device:3dprinter:1\r\n"
        "EXT:\r\n"
        f"USN: {PRINTER_SERIAL}\r\n"
        "Cache-Control: max-age=1800\r\n"
        f"DevModel.bambu.com: {PRINTER_MODEL}\r\n"
        f"DevName.bambu.com: {PRINTER_NAME}\r\n"
        f"DevSignal.bambu.com: {DEV_SIGNAL}\r\n"
        f"DevConnect.bambu.com: {DEV_CONNECT}\r\n"
        f"DevBind.bambu.com: {DEV_BIND}\r\n"
        "\r\n"
    )
    return msg.encode("ascii")


def main():
    print(f"Announcing '{PRINTER_NAME}' ({PRINTER_IP}) to Bambu Studio every "
          f"{ANNOUNCE_INTERVAL_SECONDS}s. Press Ctrl+C to stop.")
    message = build_message()
    with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
        try:
            while True:
                sock.sendto(message, (TARGET_IP, TARGET_PORT))
                print(f"  sent announce for {PRINTER_NAME} ({PRINTER_IP})")
                time.sleep(ANNOUNCE_INTERVAL_SECONDS)
        except KeyboardInterrupt:
            print("\nStopped.")


if __name__ == "__main__":
    main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment