LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-18-2016, 09:56 PM   #1
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Firewall config for Debian server running MySQL


So I am renting this server because I need to host some MySQL databases. I can ssh into the server but have no physical access to it. It's not currently running a firewall, which is not good security practice. I want to setup a firewall on it, but am afraid of locking myself out.

What is the usual way of setting up a firewall on a remote server without locking yourself out ?

Haven't been here in a while, I know. I've been busy.

EDIT: P.S. This is a production server. I'll be doing this not during working hours, but if something happens that I can't fix overnight, I'm fired...

Last edited by metaschima; 04-18-2016 at 09:58 PM.
 
Old 04-19-2016, 01:08 AM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
While you are testing, set up a cron job to clear your iptables rules every 30 mins or so.
What else is running on the server?
Do you want to restrict access to your MySQL by ip?
Otherwise, what do you hope to achieve with your firewall rules?
 
1 members found this post helpful.
Old 04-19-2016, 03:26 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,359
Blog Entries: 3

Rep: Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767
There are at least two ways of setting up a remote firewall without locking yourself out. One is to save the last known working firewall rules and then use an 'at' job to automatically restore them after a few minutes. That gives a short window to test the new rules and limits the possible lockout to the time until the at job. Another method is to use 'iptables-apply'. See the manual pages for either 'at' or 'iptables-apply'
 
1 members found this post helpful.
Old 04-19-2016, 08:01 AM   #4
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Original Poster
Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Thanks, that makes sense, an at or cron job would do it.

The server is running MySQL and Bittorrent Sync. That's about it. Then I need SSH access.

I did restrict MySQL access by IP only.

What do I want to achieve with the firewall rules. I guess since I'm only running these two services, it won't help much will it. I'm just trying to secure the server.

I have disallowed root login to SSH. I'll disable unused services. Other ideas are welcome.
 
Old 04-19-2016, 11:04 AM   #5
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
Here are some thoughts:
  1. Secure ssh access with a key instead of passwords.
  2. Drop everything that does not need access.
  3. Setup the firewall to allow only those that require it.
  4. Install Fail2ban and completely block anything that fails the second attempt to login after you got keys setup and functioning properly for ssh.
 
1 members found this post helpful.
Old 04-19-2016, 01:20 PM   #6
devilboy09
Member
 
Registered: Nov 2011
Location: Iran
Distribution: Debian, CentOS, LFS, CloudLinux
Posts: 377

Rep: Reputation: 10
if you afraid of locking yourself out when you're configuring the firewall, i suggest you to use an excellent package named screen.
with screen you can have multiple terminals and your access to the server will be fine even if your connection is disrupted by a firewall rule.
 
Old 04-19-2016, 02:27 PM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,359
Blog Entries: 3

Rep: Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767Reputation: 3767
screen or tmux can help you keep your work flow but it won't let you back in if you lock yourself out with the firewall. cron, at, or iptables-apply would be the way to let yourself back in.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running a Gateway/Firewall/IPS on Debian Squeeze Emisand Linux - Security 5 03-22-2012 04:09 PM
mail server firewall help with config sir-lancealot! Linux - Server 5 09-05-2006 08:52 PM
probs running MYSQL-SERVER on debian bennethos Debian 4 10-30-2004 08:10 AM
IP config: net/firewall/server/W2K darb Linux - Networking 7 03-31-2004 05:18 PM
Apache / PHP / Mysql config problem - debian bandit Linux - Software 14 09-03-2003 09:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration