LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-15-2019, 09:37 AM   #1
elliot01
Member
 
Registered: Jun 2009
Location: UK
Distribution: CentOS / RedHat
Posts: 89

Rep: Reputation: 16
Question Alternative to /etc/hosts/allow on CentOS8


Hi all,

What's the alternative to using /etc/hosts.allow under RHEL/CentOS 8?

A little research indicates that hosts.{allow,denied} files are obsolete. The same articles seem to suggest using firewalld instead.

My issue is that we don't run firewalld on any of our RHEL/CentOS systems, so am unable to use that. Is there a simpler alternative, similar to how hosts.allow worked?

Thank you!
 
Old 10-15-2019, 10:16 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,306
Blog Entries: 3

Rep: Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720
One alternative for filtering is iptables, or its front-end UFW.

What were you trying to do with TCPwrappers anyway? It has been made redundant since the 1990s, except for a few weird use-cases which also expired shortly thereafter.
 
Old 10-15-2019, 10:46 AM   #3
elliot01
Member
 
Registered: Jun 2009
Location: UK
Distribution: CentOS / RedHat
Posts: 89

Original Poster
Rep: Reputation: 16
Hi, I just wanted to ensure only SSH connections from 10.x.x.x are accepted.

For instance, our /etc/hosts.allow on all our applicable servers contains:

"
sshd : 10. : allow
sshd : ALL : deny
"

This has been working as expected. So just wanted a quick easy alternative for CentOS8.

Cheers
 
Old 10-15-2019, 10:49 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,306
Blog Entries: 3

Rep: Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720Reputation: 3720
Ok. You can, and probably should, do that with iptables.

Alternatively you could take a look at adding Match blocks in /etc/ssh/sshd_config and set up something for Match Address. See "man sshd_config" for that.
 
Old 10-16-2019, 05:45 AM   #5
elliot01
Member
 
Registered: Jun 2009
Location: UK
Distribution: CentOS / RedHat
Posts: 89

Original Poster
Rep: Reputation: 16
Forgive my noobness, but is iptables the spirutual/direct predecessor to firewalld? Or is there still a use case for both?

I suppose what I wish to clarify is whether I should indeed use iptables, or just move straight to firewalld.

Thank you for your time
 
Old 10-16-2019, 07:14 AM   #6
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,617

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
Quote:
Originally Posted by elliot01 View Post
Forgive my noobness, but is iptables the spirutual/direct predecessor to firewalld? Or is there still a use case for both?

I suppose what I wish to clarify is whether I should indeed use iptables, or just move straight to firewalld.

Thank you for your time
iptables is more the parent of forewalld. Either would serve your purpose.
 
Old 10-16-2019, 08:11 AM   #7
elliot01
Member
 
Registered: Jun 2009
Location: UK
Distribution: CentOS / RedHat
Posts: 89

Original Poster
Rep: Reputation: 16
Okay, thank you
 
Old 10-16-2019, 09:47 AM   #8
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
I'm certainly no expert, but it is my understanding that firewalld (which I'm learning) is a "front-end" to iptables (about which I have absolutely no clue), and that the "rules" entered in firewalld became entries in iptables.

Do I have that right?
 
Old 10-23-2019, 06:54 AM   #9
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749Reputation: 2749
Actual packet filtering is conducted by the Linux kernel using the Netfilter framework.
iptables (formerly ipchains) is the traditional user space tool (amongst others) used to manipulate Netfilter.
firewalld is a front end to iptables.

The kernel Netfilter framework has been re-engineered to a new framework nftables with a new user space tool, nft, that helps with handling newer networking technologies.

Last edited by allend; 10-23-2019 at 08:22 AM. Reason: Clarity
 
Old 10-28-2019, 06:10 PM   #10
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,900

Rep: Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050
The officially supported method of configuring your CentOS or RHEL firewall, is by using firewalld. Some people like to strip out Network Manager and bypass firewalld in favor of iptables/ip6tables, but I do not recommend doing so if your goal is to learn CentOS. Stick to the design.

The RHEL8 documentation on firewalld should cover all the basic configuration.

https://access.redhat.com/documentat...uring-networks
 
1 members found this post helpful.
Old 10-28-2019, 06:27 PM   #11
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by mralk3 View Post
The officially supported method of configuring your CentOS or RHEL firewall, is by using firewalld. Some people like to strip out Network Manager and bypass firewalld in favor of iptables/ip6tables, but I do not recommend doing so if your goal is to learn CentOS. Stick to the design.

The RHEL8 documentation on firewalld should cover all the basic configuration.

https://access.redhat.com/documentat...uring-networks
"Stick to the design" is certainly valid advice, but I presume that if one already knows iptables, it would still be valid to use it instead. (I didn't, so I am learning firewalld -- 'tho I've not yet moved to CentOS 8).
Otherwise, I agree with you. Bite the bullet and learn the new way (systemd, anyone? -- not that there's much of an option there )

Thank you for posting that link...Much easier to work with than the man pages.
 
1 members found this post helpful.
Old 10-28-2019, 10:49 PM   #12
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,900

Rep: Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050Reputation: 1050
Quote:
Originally Posted by scasey View Post
"Stick to the design" is certainly valid advice, but I presume that if one already knows iptables, it would still be valid to use it instead. (I didn't, so I am learning firewalld -- 'tho I've not yet moved to CentOS 8).
Otherwise, I agree with you. Bite the bullet and learn the new way (systemd, anyone? -- not that there's much of an option there )

Thank you for posting that link...Much easier to work with than the man pages.
The default network packet filter in RHEL 8 is nftables-NOT iptables. Red hat is making a big push toward firewalld.
 
Old 01-11-2021, 08:33 AM   #13
Tobler
LQ Newbie
 
Registered: Oct 2007
Distribution: Ubuntu, RedHat Enterprise Linux
Posts: 14

Rep: Reputation: 0
tcp-wrapper vs firewall

Hi

I would love still to use tcp-wrapper as it has features what firewall is not capable of doing.
Like - it can not filter port by remote host name. So it's kind of MFA protection to your TCP services.

Like on /etc/hosts.allow you could have:
ALL: 192.168.* # allow your local network
sshd: *.cc *.myisp.net # for SSH, allow only from your country cc and from your own ISP (or mobile operator)

/etc/hosts.deny should have:
ALL: ALL # Deny everything else

But because tcpwrappers are not supported on "modern" Linux systems - there should be systemd/socket option for it. Or compile your own tcpd -program to be called for each TCP based service which then would launch actual process.

On old days there was inetd services which were launched when something connected to port being listened. And first it launched tcpd (tcpwrapper) and if connection was accepted then actual process (like telnetd or sshd).

Br, Tobler
 
Old 01-11-2021, 10:12 AM   #14
Tobler
LQ Newbie
 
Registered: Oct 2007
Distribution: Ubuntu, RedHat Enterprise Linux
Posts: 14

Rep: Reputation: 0
tcp-wrapper vs firewall

Hi

I would love still to use tcp-wrapper as it has features what firewall is not capable of doing.
Like - it can not filter port by remote host name. So it's kind of MFA protection to your TCP services.

Like on /etc/hosts.allow you could have:
ALL: 192.168.* # allow your local network
sshd: *.cc *.myisp.net # for SSH, allow only from your country cc and from your own ISP (or mobile operator)

/etc/hosts.deny should have:
ALL: ALL # Deny everything else

But because tcpwrappers are not supported on "modern" Linux systems - there should be systemd/socket option for it. Or compile your own tcpd -program to be called for each TCP based service which then would launch actual process.

On old days there was inetd services which were launched when something connected to port being listened. And first it launched tcpd (tcpwrapper) and if connection was accepted then actual process (like telnetd or sshd).

Br, Tobler
 
  


Reply

Tags
centos, rhel, ssh



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
Verify /etc/hosts usage and round robin in /etc/hosts MikeyCarter Linux - Software 1 06-24-2008 12:20 PM
How to allow a router's address in /etc/hosts.allow? xpucto Linux - Newbie 1 02-26-2008 05:28 AM
/etc/hosts.deny/hosts.allow have no effect on sshd access bganesh Linux - Security 4 05-04-2006 08:06 PM
hosts.deny and hosts.allow defaults? gui10 Linux - Security 5 12-20-2001 01:57 AM
hosts.allow / hosts.deny fistz Linux - Newbie 1 04-19-2001 07:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:41 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