Help us understand the problem. What is going on with this article?

Ubuntuのポート開放方法(ファイアウォールを設定する)

More than 1 year has passed since last update.

pythonでsocketを使っていたときに少し躓いたので、メモを残しておく。

とりあえずポートを開放する

現在の状態を確認

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
22 (v6)                    ALLOW       Anywhere (v6)

この例だと、22番ポート(ssh)しか通らない。
apacheを使いたい場合など、80番ポートを開けたいときには、以下のようにする。

$ sudo ufw allow 80
$ sudo ufw reload
$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere
22 (v6)                    ALLOW       Anywhere (v6)
80                         ALLOW       Anywhere
80 (v6)                    ALLOW       Anywhere (v6)

80番ポートが開いた。これで無事にapacheのスタートページが見られるようになる。

その他便利なコマンド

システムでファイアーウォールを有効/無効にする。

$ sudo ufw enable
$ sudo ufw disable

すべてのポートを閉じる/開く。

$ sudo ufw default DENY
$ sudo ufw default ALLOW

下手に全ポートを閉じたらsshから作業できなくなるので、
実機を直接いじれる場合にだけ試すこと。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away