为了达到这个目的,我们需要开通以下TCP端口(如果使用防火墙):

    1. 22 (SSH)
    2. 1798
    3. 5900 - 6100 (VNC 控制台)

    如何打开这些端口取决于你使用的发行版本。在RHEL/CentOS 及Ubuntu中的示例如下。

    在RHEL/CentOS中打开端口

    RHEL 及 CentOS使用iptables作为防火墙,执行以下iptables命令来开启端口:

    1. $ iptables -I INPUT -p tcp -m tcp --dport 1798 -j ACCEPT
    1. $ iptables -I INPUT -p tcp -m tcp --dport 16509 -j ACCEPT
      1. $ iptables-save > /etc/sysconfig/iptables

      在Ubuntu中打开端口:

      Ubuntu中的默认防火墙是UFW(Uncomplicated FireWall),使用Python围绕iptables进行包装。

      要打开所需端口,请执行以下命令:

      1. $ ufw allow proto tcp from any to any port 1798
      1. $ ufw allow proto tcp from any to any port 16509
      1. $ ufw allow proto tcp from any to any port 49152:49216

      默认情况下,Ubuntu中并未启用UFW。在关闭情况下执行这些命令并不能启用防火墙。