Sharing Wi-Fi via the Command Line: A Complete Guide for Windows

You can turn your laptop or desktop PC into a Wi-Fi hotspot without any third-party software – built-in tools are sufficient. Windows and several teams in command lineThis method is useful for Windows 10 and 11 when you urgently need to share internet with a phone, tablet, or another computer, but don't have a router handy. However, there are some caveats, ranging from limitations on the number of connected devices to issues with network adapter drivers.

Many users mistakenly believe that distributing Wi-Fi through CMD — is for advanced administrators. In reality, the process takes no more than 5 minutes if you know the exact sequence of actions and potential pitfalls. In this article, we'll cover not only the basic commands but also common errors (for example, Failed to start hosted network), ways to fix them, as well as alternative methods for cases when the command line refuses to cooperate.

⚠️ Attention: Before setting up, make sure that your Wi-Fi adapter supports the mode Hosted Network (virtual access point). Outdated drivers or cheap USB adapters often lack this feature. Check compatibility via device Manager or on the manufacturer's website.

Preparing the system: checking compatibility and permissions

Before you begin creating a virtual network, you need to make sure your system is ready for this operation. First, check Windows versionThe method works on Windows 10 (starting with version 1607) And Windows 11, but older editions (such as Windows 7) may require additional updates or third-party software.

Second, you need administrator rights. The command line must be launched as administrator, otherwise the commands simply won't run. To check your current permissions, enter CMD:

net session >nul 2>&1

if %errorLevel% equ 0 (

echo Administrator rights are present

) else (

echo Administrator rights required

)

Third - support Hosted Network your network adapter. You can find this out using the command:

netsh wlan show drivers

Look for the line in the output Hosted network support. If it is indicated there Yes — we can continue. If No — update the adapter driver or use alternative methods (we will discuss them below).

📊 How often do you share Wi-Fi from your laptop?
Often, almost every day
Sometimes, if necessary
I tried before, but gave up.
Never tried it

Basic commands for distributing Wi-Fi

The entire setup process comes down to two key commands: creating a network and starting it. Here are the step-by-step instructions:

  1. Network creation (set your name and password):
    netsh wlan set hostednetwork mode=allow ssid="MyWiFi" key="12345678" keyUsage=persistent

    Here:

    • 🔹 ssid="MyWiFi" — the name of your network (can be replaced with any).
    • 🔹 key="12345678" — password (minimum 8 characters).
    • 🔹 keyUsage=persistent - saves settings after reboot.
  • Network launch:
    netsh wlan start hostednetwork
  • After running the second command, your access point should appear in the list of networks on other devices. However, this is not enough—you need to enable internet sharing through the created network. We'll discuss this in the next section.

    The network adapter supports Hosted Network|

    Command prompt run as administrator|

    The network name (SSID) does not contain Cyrillic or special characters|

    Password must be at least 8 characters long-->

    Setting up Internet sharing

    To enable internet access for connected devices, you need to share your current connection. To do this:

    1. Open Control Panel → Network and Internet → Network and Sharing Center.
    2. In the left menu, select Changing adapter settings.
    3. Find your primary internet connection (eg. Ethernet or Wireless network), right-click and select Properties.
    4. Go to the tab Access and check the box Allow other network users to use this computer's Internet connection.
    5. In the drop-down list Connecting a home network select the network you created (usually it's called Local Area Connection* X, where X is a number).
    6. Important: If your network is not listed, check if it is started with the command netsh wlan start hostednetworkSometimes restarting the adapter helps. Device Manager.

      ⚠️ Attention: Once you set up sharing, your computer will act as a "router," and all devices on the network will use its IP address to access the internet. This can cause problems if your ISP limits the number of MAC addresses or blocks traffic sharing.

      Problem Possible cause Solution
      The network does not start (Failed to start hosted network) Outdated Wi-Fi adapter driver Update driver via device Manager or from the manufacturer's website
      The devices connect, but there is no internet. Sharing is not configured Check the settings in Network and Control Center (see instructions above)
      The network disappears after rebooting Settings not saved persistent Repeat the network creation command with the flag keyUsage=persistent
      Low distribution speed Wi-Fi adapter or channel limitations Try changing the channel with the command netsh wlan set hostednetwork channel=6

      Advanced settings: change channel, network name, password

      Basic commands are sufficient for a one-time distribution, but if you plan to use the virtual network regularly, it is useful to know how to customize it. For example, change the Wi-Fi channel (by default it is selected automatically, but in conditions of interference it is better to set it manually):

      netsh wlan set hostednetwork channel=9

      Valid channel values: from 1 to 14 (depending on the region). To check the channel load, use programs like Wi-Fi Analyzer (Android) or inSSIDer (Windows).

      For changing the network name (SSID) or password Re-run the network creation command with the new parameters:

      netsh wlan set hostednetwork mode=allow ssid="NewWiFiName" key="newpassword123" keyUsage=persistent

      ⚠️ Attention: When you change your password, all connected devices will be disconnected and will need to re-authorize with the new credentials. If you are using sharing for IoT devices (such as smart bulbs), they may need to be reconfigured.

      How can I find out my current network settings?

      Display information about the created network with the command:

      netsh wlan show hostednetwork settings=security

      The output will display:

      - Network name (SSID)

      - Authentication type (usually WPA2-PSK)

      - Number of connected devices (in the section Number of users)

      Automating network startup when the PC is turned on

      If you frequently share Wi-Fi, entering commands manually each time can be tedious. There are two ways to automate this process:

      1. Creating a file (.bat):
        • 📄 Open Notebook and enter:
          @echo off
          

          netsh wlan start hostednetwork

          pause

        • 💾 Save the file with the extension .bat (For example, start_wifi.bat).
        • 🖱️ Put it in startup or run it manually.
    7. Windows Task Scheduler:
      • 📅 Open Task Scheduler (taskschd.msc).
      • 🔄 Create a task with a trigger When starting the computer.
      • 📝 Specify the command in the action netsh wlan start hostednetwork.

    Important: Automatic network startup may conflict with some antivirus programs (for example, Kaspersky Internet Security blocks Hosted Network by default). In this case, add an exception for the command netsh.exe in the antivirus settings.

    @echo off
    

    timeout /t 10

    netsh wlan start hostednetwork

    This will give your network adapters time to initialize after Windows boots.-->

    Alternative ways to share Wi-Fi without CMD

    The command line isn't the only way to share the internet. If you're having trouble setting it up Hosted Network, try alternatives:

    • 🪟 Windows Mobile Hotspot:

      IN Windows 10/11 there is a built-in function Mobile hotspot (Settings → Network & Internet → Mobile Hotspot). It is easier to set up, but has limitations:

      • Maximum 8 connected devices (versus 100+ in some routers).
      • It is not possible to change the channel or encryption type.

    • 🔧 Third-party programs:

      Utilities like Connectify Hotspot, MyPublicWiFi or Virtual Router Plus offer advanced features:

      • 📊 Monitoring traffic of connected devices.
      • 🔒 Blocking unwanted websites.
      • 📶 Automatic selection of the least loaded channel.

    ⚠️ Attention: Third-party programs may contain adware or collect traffic data. Download them only from official websites and check user reviews.

    Security when sharing Wi-Fi from a PC

    Sharing Wi-Fi from your computer creates potential vulnerabilities for your network. Here are some key precautions:

    • 🔐 Complex password:

      Use a password that is at least 12 characters with a mixture of letters, numbers, and special characters. Avoid simple combinations like 12345678 or qwerty - they are hacked in seconds.

    • 🛡️ Network shutdown when idle:

      If you are not using distribution, disable it with the command:

      netsh wlan stop hostednetwork

      This will reduce the risk of unauthorized connection.

    • 👥 Limiting connected devices:

      By default, Windows allows you to connect up to 100 devices, but that doesn't mean you need to allow everyone. Manually manage the list of connected gadgets.

    Additional protection: If you are distributing Wi-Fi in a public place (such as a cafe or co-working space), consider using VPN on the main device. This will hide your real IP address from connected clients.

    FAQ: Frequently asked questions about sharing Wi-Fi via CMD

    Is it possible to share Wi-Fi from a PC if the Internet is connected via a USB modem (3G/4G)?

    Yes, but with some caveats. Most USB modems (for example, from Megaphone or Beeline) block traffic distribution by default. To bypass the restriction:

    1. Install the official modem software (for example, MegaFon Internet).
    2. Find the option in the program settings Allow sharing.
    3. If there is no option, try creating a connection via Telephone and modem in Windows and share it.

    ⚠️ Please note that some operators charge for traffic distribution separately (for example, the tariff For laptop at Tele2).

    Why is the internet speed when distributing from a PC lower than through a router?

    This is due to several factors:

    • 📡 Wi-Fi adapter limitations: Built-in laptop adapters usually support the standard Wi-Fi 5 (802.11ac) at a maximum speed of up to 867 Mbps, while modern routers work on Wi-Fi 6 (802.11ax) at a speed of up to 2400 Mbps.
    • 🖥️ CPU load: The PC spends resources on traffic encryption and routing, which can reduce the speed of 10-30%.
    • 🔌 Internet connection type: If your PC is connected to the network via Ethernet, and distributes by Wi-Fi, the speed is limited by the weakest link (usually Wi-Fi).

    To improve speed:

    • Use an adapter that supports it. Wi-Fi 6 (For example, TP-Link Archer TX3000E).
    • Connect your PC to the Internet via Ethernet, not a USB modem.
    • Reduce the number of connected devices.

    How to share Wi-Fi from a MacBook (macOS)?

    On macOS the process is simpler than in Windows:

    1. Open System Preferences → Sharing.
    2. Select Public Internet in the left menu.
    3. In the field General connection Please indicate your internet source (e.g. Ethernet or Wi-Fi).
    4. In the field For computers using mark Wi-Fi.
    5. Click Wi-Fi settings and set the network name, channel, security type (WPA2/WPA3) and password.
    6. Activate sharing using the button on the left.

    ⚠️ Unlike Windows, macOS allows you to distribute Wi-Fi even if the MacBook itself is connected to another wireless network (mode repeater).

    Is it possible to share Wi-Fi with Linux (Ubuntu, Debian)?

    In Linux, Wi-Fi distribution is configured through utilities hostapd And dnsmasqBrief instructions:

    1. Install packages:
      sudo apt update
      

      sudo apt install hostapd dnsmasq

    2. Set up hostapd (example config /etc/hostapd/hostapd.conf):
      interface=wlan0
      

      driver=nl80211

      ssid=MyLinuxWiFi

      hw_mode=g

      channel=6

      wpa=2

      wpa_passphrase=12345678

      wpa_key_mgmt=WPA-PSK

    3. Start the access point:
      sudo systemctl start hostapd
      

      sudo systemctl start dnsmasq

    To automatically start at boot, use:

    sudo systemctl enable hostapd
    

    sudo systemctl enable dnsmasq

    How do I find out who is connected to my shared network?

    Windows doesn't have a built-in tool for monitoring connected devices, but there are workarounds:

    • 📊 Via the command line:
      arp -a

      Displays a list of IP and MAC addresses of devices on your local network. However, this method shows all devices, not just those connected to your access point.

    • 🔍 Third-party programs:
      • Wireless Network Watcher (from NirSoft) — scans the network and displays connected gadgets with the manufacturer indicated (by MAC address).
      • GlassWire — monitors traffic and displays active connections.
    • 📱 Mobile applications:

      If you have a smartphone connected to the network, use applications like Fing (Android/iOS) for scanning devices.