我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们
文章版本: Enterprise Server 2.20

Configuring built-in firewall rules

You can view default firewall rules and customize rules for 您的 GitHub Enterprise Server 实例.

本文内容

About 您的 GitHub Enterprise Server 实例's firewall

GitHub Enterprise Server uses Ubuntu's Uncomplicated Firewall (UFW) on the virtual appliance. For more information see "UFW" in the Ubuntu documentation. GitHub Enterprise Server automatically updates the firewall allowlist of allowed services with each release.

After you install GitHub Enterprise Server, all required network ports are automatically opened to accept connections. Every non-required port is automatically configured as deny, and the default outgoing policy is configured as allow. Stateful tracking is enabled for any new connections; these are typically network packets with the SYN bit set. For more information, see "Network ports."

The UFW firewall also opens several other ports that are required for GitHub Enterprise Server to operate properly. For more information on the UFW ruleset, see the UFW README.

Viewing the default firewall rules

  1. SSH 连接到 您的 GitHub Enterprise Server 实例。
    $ ssh -p 122 admin@HOSTNAME
  2. To view the default firewall rules, use the sudo ufw status command. You should see output similar to this:
    $ sudo ufw status
    > Status: active
    > To                         Action      From
    > --                         ------      ----
    > ghe-1194                   ALLOW       Anywhere
    > ghe-122                    ALLOW       Anywhere
    > ghe-161                    ALLOW       Anywhere
    > ghe-22                     ALLOW       Anywhere
    > ghe-25                     ALLOW       Anywhere
    > ghe-443                    ALLOW       Anywhere
    > ghe-80                     ALLOW       Anywhere
    > ghe-8080                   ALLOW       Anywhere
    > ghe-8443                   ALLOW       Anywhere
    > ghe-9418                   ALLOW       Anywhere
    > ghe-1194 (v6)              ALLOW       Anywhere (v6)
    > ghe-122 (v6)               ALLOW       Anywhere (v6)
    > ghe-161 (v6)               ALLOW       Anywhere (v6)
    > ghe-22 (v6)                ALLOW       Anywhere (v6)
    > ghe-25 (v6)                ALLOW       Anywhere (v6)
    > ghe-443 (v6)               ALLOW       Anywhere (v6)
    > ghe-80 (v6)                ALLOW       Anywhere (v6)
    > ghe-8080 (v6)              ALLOW       Anywhere (v6)
    > ghe-8443 (v6)              ALLOW       Anywhere (v6)
    > ghe-9418 (v6)              ALLOW       Anywhere (v6)

Adding custom firewall rules

Warning: Before you add custom firewall rules, back up your current rules in case you need to reset to a known working state. If you're locked out of your server, contact GitHub Enterprise 支持GitHub 高级支持 to reconfigure the original firewall rules. Restoring the original firewall rules involves downtime for your server.

  1. Configure a custom firewall rule.
  2. Check the status of each new rule with the status numbered command.
    $ sudo ufw status numbered
  3. To back up your custom firewall rules, use the cpcommand to move the rules to a new file.
    $ sudo cp -r /lib/ufw ~/ufw.backup

After you upgrade 您的 GitHub Enterprise Server 实例, you must reapply your custom firewall rules. We recommend that you create a script to reapply your firewall custom rules.

Restoring the default firewall rules

If something goes wrong after you change the firewall rules, you can reset the rules from your original backup.

Warning: If you didn't back up the original rules before making changes to the firewall, contact GitHub Enterprise 支持GitHub 高级支持 for further assistance.

  1. SSH 连接到 您的 GitHub Enterprise Server 实例。
    $ ssh -p 122 admin@HOSTNAME
  2. To restore the previous backup rules, copy them back to the firewall with the cp command.
    $ sudo cp -f ~/ufw.backup/*rules /lib/ufw
  3. Restart the firewall with the systemctl command.
    $ sudo systemctl restart ufw
  4. Confirm that the rules are back to their defaults with the ufw status command.
    $ sudo ufw status
    > Status: active
    > To                         Action      From
    > --                         ------      ----
    > ghe-1194                   ALLOW       Anywhere
    > ghe-122                    ALLOW       Anywhere
    > ghe-161                    ALLOW       Anywhere
    > ghe-22                     ALLOW       Anywhere
    > ghe-25                     ALLOW       Anywhere
    > ghe-443                    ALLOW       Anywhere
    > ghe-80                     ALLOW       Anywhere
    > ghe-8080                   ALLOW       Anywhere
    > ghe-8443                   ALLOW       Anywhere
    > ghe-9418                   ALLOW       Anywhere
    > ghe-1194 (v6)              ALLOW       Anywhere (v6)
    > ghe-122 (v6)               ALLOW       Anywhere (v6)
    > ghe-161 (v6)               ALLOW       Anywhere (v6)
    > ghe-22 (v6)                ALLOW       Anywhere (v6)
    > ghe-25 (v6)                ALLOW       Anywhere (v6)
    > ghe-443 (v6)               ALLOW       Anywhere (v6)
    > ghe-80 (v6)                ALLOW       Anywhere (v6)
    > ghe-8080 (v6)              ALLOW       Anywhere (v6)
    > ghe-8443 (v6)              ALLOW       Anywhere (v6)
    > ghe-9418 (v6)              ALLOW       Anywhere (v6)

问问别人

找不到要找的内容?

联系我们