How to Open Ports in Linux Server Firewall
SSH into your server as Root: ~ >>; , Get to the directory where the configuration file is for CSF: ~ >> cd /etc/csf Press (Enter) Note: This is where CSF keeps all of its files, not just the configuration file. , Open the configuration file so that...
Step-by-Step Guide
-
Step 1: SSH into your server as Root: ~ >>;
Something like "Vim" editor is good because it's nice and easy.
If you use a different editor that is fine, just know that the commands showing are for "Vim." csf >> vim csf.conf Press (Enter) Note:
This file has a lot of great security settings in it that you can tweak to your needs, but I am not going to be going into those here.
You can read the comments in the file and they do a great job of explaining what each setting does.
Once you have the file open, you will see a "TCP_IN" and "TCP_OUT" section.
It will look like this: ,, Yours may look different so don't panic! It all depends on your configuration. , This is where we are going to add our port. 2095, 2096, 8000[]" Since we are using "Vim" we need some special commands.
Press the on your keyboard.
This will allow you to enter "Vims"
-
- insert
-
- mode so you can add text. ,, This will get you out of
-
-insert-
- mode. , Hold the (Shift) key and press ( ; ).
At the bottom, ( : ) should appear with a blinking cursor. , This stands for
-write and
-quit. , csf >> service csf restart Press (Enter) You will see this: ,, Don't Worry! These are all IPs that have either been blacklisted or whitelisted and are being put back into the firewall.
This will only take like five seconds (unless you have a huge list). , -
Step 2: Get to the directory where the configuration file is for CSF: ~ >> cd /etc/csf Press (Enter) Note: This is where CSF keeps all of its files
-
Step 3: not just the configuration file.
-
Step 4: Open the configuration file so that we can edit it.
-
Step 5: Allow incoming TCP ports TCP_IN = "20
-
Step 6: 8000"
-
Step 7: Allow outgoing TCP ports TCP_OUT = "20
-
Step 8: 8000" All those numbers there are ports that are currently "open".
-
Step 9: Navigate down to the end of those lines after where you see that 8000 number.
-
Step 10: Type in the port number: 2095
-
Step 11: 8001[]" Do this for the TCP_OUT as well.
-
Step 12: When you are finished
-
Step 13: hold the (Ctrl) key on your keyboard and press the bracket button ( [ ).
-
Step 14: Save and get out of this file.
-
Step 15: Type the letters (w) and (q)
-
Step 16: with no spaces.
-
Step 17: Restart the firewall so that your changes take effect!
-
Step 18: Stopping CSF
-
Step 19: Then you will see (if any were in the blacklist or whitelist) a bunch of IPs flying across your screen.
-
Step 20: When you see this
-
Step 21: You are Done!
Detailed Guide
Something like "Vim" editor is good because it's nice and easy.
If you use a different editor that is fine, just know that the commands showing are for "Vim." csf >> vim csf.conf Press (Enter) Note:
This file has a lot of great security settings in it that you can tweak to your needs, but I am not going to be going into those here.
You can read the comments in the file and they do a great job of explaining what each setting does.
Once you have the file open, you will see a "TCP_IN" and "TCP_OUT" section.
It will look like this: ,, Yours may look different so don't panic! It all depends on your configuration. , This is where we are going to add our port. 2095, 2096, 8000[]" Since we are using "Vim" we need some special commands.
Press the on your keyboard.
This will allow you to enter "Vims"
-
- insert
-
- mode so you can add text. ,, This will get you out of
-
-insert-
- mode. , Hold the (Shift) key and press ( ; ).
At the bottom, ( : ) should appear with a blinking cursor. , This stands for
-write and
-quit. , csf >> service csf restart Press (Enter) You will see this: ,, Don't Worry! These are all IPs that have either been blacklisted or whitelisted and are being put back into the firewall.
This will only take like five seconds (unless you have a huge list). ,
About the Author
Stephanie Hill
Writer and educator with a focus on practical lifestyle knowledge.
Rate This Guide
How helpful was this guide? Click to rate: