900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 防火墙设置开放端口

防火墙设置开放端口

时间:2020-04-26 01:43:55

相关推荐

防火墙设置开放端口

一 访问linux的nginx

1.1 描述

在windows的系统中访问linux的nginx,默认是不能访问的,原因在于防火墙。解决办法

1.关闭防火墙;

2.开启防火墙,在防火墙中设置指定对外访问的端口。

查看端口:firewall-cmd --list-all

设置开放端口:

firewall-cmd --add-service=http --permanent

firewall-cmd --add-port=80/tcp --permanent

重启防火墙:

firewall-cmd --reload

二 查看防火墙端口

2.1 查看防火墙状态

[root@localhost ~]#systemctl status firewalld

● firewalld.service - firewalld - dynamic firewall daemon

Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

Active: inactive (dead)

Docs: man:firewalld(1)

[root@localhost ~]# pwd

2.2 开启防火墙

[root@localhost sbin]# systemctl start firewalld

[root@localhost sbin]# systemctl status firewalld

● firewalld.service - firewalld - dynamic firewall daemon

Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

Active: active (running) since Thu -05-06 19:00:49 CST; 35min ago

Docs: man:firewalld(1)

Main PID: 2904 (firewalld)

Tasks: 2

CGroup: /system.slice/firewalld.service

└─2904 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

May 06 19:00:49 localhost.localdomain systemd[1]: Starting firewalld - dyna...

May 06 19:00:49 localhost.localdomain systemd[1]: Started firewalld - dynam...

Hint: Some lines were ellipsized, use -l to show in full.

2.3 查看端口

[root@localhost sbin]#firewall-cmd --list-all

public (active)

target: default

icmp-block-inversion: no

interfaces: ens33

sources:

services: ssh dhcpv6-client

ports:

protocols:

masquerade: no

forward-ports:

source-ports:

icmp-blocks:

rich rules:

2.4 开启制定端口

[root@localhost sbin]#firewall-cmd --add-service=http --permanent

success

[root@localhost sbin]#firewall-cmd --add-port=80/tcp --permanent

success

1.5 重启防火墙

[root@localhost sbin]#firewall-cmd --reload

success

[root@localhost sbin]#firewall-cmd --list-all

public (active)

target: default

icmp-block-inversion: no

interfaces: ens33

sources:

services: ssh dhcpv6-client http

ports: 80/tcp

protocols:

masquerade: no

forward-ports:

source-ports:

icmp-blocks:

rich rules:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。