如何在VMware中开放8100端口?如何访问Linux虚拟机的8100端口?
Hey there! Let's work through those two port-related issues you're hitting with Lubuntu on VMware—especially since you already messed with iptables and still got that annoying "Connection refused" error. Let's break this down step by step.
The setup depends on which network mode your VMware virtual machine is using—let's cover the two most common ones:
NAT模式(默认常用)
- Open VMware, right-click your Lubuntu VM and select Settings.
- Go to the Network Adapter tab, make sure NAT is selected, then click NAT Settings.
- In the NAT Settings window, hit Add to create a port forwarding rule:
- Host Port:
8100 - Virtual Machine Port:
8100 - Virtual Machine IP Address: Enter your Lubuntu VM's internal IP (you can get this by running
ip ain the VM's terminal—look for theinetline under your active network interface, likeenp0s3).
- Host Port:
- Save the rule and restart your VM to apply changes.
桥接模式(虚拟机和主机在同一局域网)
If you're using Bridged mode, you don't need extra port forwarding in VMware—just make sure your VM and host are on the same network segment. The key here is ensuring your VM has a valid IP on your local network (check with ip a again).
Since you already configured iptables and still have issues, let's rule out the most common culprits:
Step 1: Verify your service is actually listening on 8100
The #1 reason for "Connection refused" is that no service is running on that port. In your Lubuntu terminal, run:
ss -tulpn | grep 8100
- If you get no output: Your service isn't started, or it's configured to only listen on
127.0.0.1(localhost, which can't be accessed from outside the VM). Check your service's config to make sure it binds to0.0.0.0(all interfaces) instead of just localhost. - If you see output like
LISTEN 0 100 0.0.0.0:8100 0.0.0.0:* users:(("your-service",pid=1234,fd=5)), then the service is listening correctly—move to the next step.
Step 2: Double-check your firewall rules
Even if you set iptables, sometimes rules don't stick or there's another firewall (like ufw) overriding them:
- First, confirm iptables allows 8100:
If you don't see a line allowingsudo iptables -L -n | grep 8100tcp dpt:8100, re-add the rule:
Save the rules so they persist after reboot:sudo iptables -A INPUT -p tcp --dport 8100 -j ACCEPTsudo iptables-save > /etc/iptables/rules.v4 - If you have ufw enabled (Lubuntu might have this by default), allow the port there too:
sudo ufw allow 8100/tcp sudo ufw reload
Step 3: Test access based on your VMware network mode
- NAT Mode: From your host machine (the one running VMware), open Safari and go to
http://localhost:8100orhttp://[your-host-ip]:8100(your host's IP is the one on your local network, e.g.,192.168.1.100). - Bridged Mode: Use your Lubuntu VM's IP address directly, like
http://[vm-ip]:8100(you got this fromip aearlier).
Step 4: Check network connectivity
If you still can't connect, make sure your host and VM can ping each other:
- From the VM, ping your host's IP:
ping [host-ip] - From the host, ping the VM's IP:
ping [vm-ip]
If pings fail, your VMware network setup is broken—go back to the Network Adapter settings and double-check the mode, or reset VMware's network configuration.
内容的提问来源于stack exchange,提问作者Whitecat

