You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac与Kali虚拟机间Netcat双向连接异常排查求助

Mac与Kali虚拟机间Netcat双向连接异常排查求助

Hey there, let's figure out why you're hitting that "Connection refused" error when trying to connect from your Mac to your Kali VM's netcat listener. Here are the most common issues to check and fix step by step:

  • Check Kali's firewall settings
    Kali's default firewall (ufw) might be blocking incoming connections on port 1234. First, run sudo ufw status in your Kali terminal—if it shows "active", that's likely the problem. You can either temporarily disable it with sudo ufw disable to test, or add a rule to allow traffic on port 1234: sudo ufw allow 1234/tcp. If you're using iptables instead, run sudo iptables -L to check for rules that might be rejecting incoming traffic on that port.

  • Verify the netcat listener is actually running correctly
    Double-check that your nc -lv 1234 command on Kali is working as expected. You should see output like listening on [any] 1234 ... to confirm it's listening on all interfaces. Also, use ss -tulpn | grep 1234 to make sure the port is actually occupied by nc—sometimes another program might be using the port, or the listener might be bound only to the loopback address (127.0.0.1), which would prevent external connections.

  • Check your VM's network mode
    This is a super common culprit. If your Kali VM is using NAT mode, it's on a private network that your Mac can't directly reach. Switch it to Bridge Mode in your virtualization software (like VirtualBox or VMware)—this will give Kali an IP address on the same local network as your Mac, making direct connections possible. Also, confirm you're using the correct IP: run ip a in Kali to get its actual local IP, not the loopback (127.0.0.1) or a NAT-internal IP.

  • Rule out Mac-side firewall/security software interference
    Even though you're connecting outward from your Mac, some firewall or third-party security tools might block outbound traffic to port 1234. Try temporarily disabling Mac's built-in firewall (go to System Settings > Network > Firewall) and test the connection again. If that works, you can add an exception for netcat or port 1234 later.

  • Double-check your nc command syntax on Mac
    Make sure you're typing the command correctly: nc ip.of.my.kali 1234. If you're having issues with IPv6, try forcing IPv4 with nc -4 ip.of.my.kali 1234—sometimes Mac defaults to IPv6 which might not be set up properly for your VM.

备注:内容来源于stack exchange,提问作者edamondo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.23 08:04:52