Home:ALL Converter>I cannot connect after enable Firewalld on CentOS7

I cannot connect after enable Firewalld on CentOS7

Ask Time:2020-11-24T17:22:28         Author:tatoline

Json Formatter

I'm trying to setup LAMP to CentOS7 with a guide. I tried to run these commands to allow HTTP and HTTPS traffic:

sudo firewall-cmd --permanent --zone=public --add-service=http 
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload

But system give this error:

FirewallD is not running

So I searched for it then apply these commands:

systemctl enable firewalld
systemctl start firewalld

Then it printed "completed" output but my connection was aborted and I cannot connect to the server with IP:Port with PuTTy anymore.

What should I do? The only access to the server was that way for me. I have no physical access to the server.

Author:tatoline,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/64983526/i-cannot-connect-after-enable-firewalld-on-centos7
Simon :

It looks like you locked yourself out, as you did not specify that ssh should also be allowed:\nsudo firewall-cmd --permanent --zone=public --add-service=http \nsudo firewall-cmd --permanent --zone=public --add-service=https\nsudo firewall-cmd --permanent --zone=public --add-service=ssh\nsudo firewall-cmd --reload\n\nThe guide above seems to assume that ssh is already allowed.\n\nWhat should I do? The only access to the server was that way for me. I have no physical access to the server.\n\nSo at this point the only way to access the server will typically be via the VM console of your hosting provider / virtualisation solution. Almost all providers will allow you access to that console, so you should try to do that. Once logged in via the console, you can then run the above command to allow SSH to regain access via SSH.",
2020-11-24T09:30:10
Jamiul Islam :

Open below file\nVi /usr/sbin/firewalld\n#!/usr/bin/python2.7 -Es\n-- coding: utf-8 --\nNote if your python version is only python o another version then rename it python2.7\nthen\nsystemctl start firewalld",
2022-01-12T05:53:45
yy