nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Linux howto allow or deny access by IP address

This is a discussion on Linux howto allow or deny access by IP address within the Linux software forums, part of the Linux Getting Started category; Iptables is full of shit. If one rule goes wrong, my ssh server and remote connectivity goes down. I am ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Linux software

Linux answers from nixCraft.


Linux software General questions and discussion about Redhat/Fedora Core/Cent OS, Debian and Ubuntu Linux related to softwares should go here.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-07-2006, 01:36 AM
Junior Member
User
 
Join Date: Jul 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
goku
Default Linux howto allow or deny access by IP address

Iptables is full of shit. If one rule goes wrong, my ssh server and remote connectivity goes down. I am just wondering if there is a way (easy way) to allow or deny access by IP Address to services such as Apache or SSH Server, mail server etc…

Currently I want to block access to certain machines…
Reply With Quote
  #2 (permalink)  
Old 10-07-2006, 07:44 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You can use any one of the following way to Allow or Deny access by IP address
a) Using IPTABLES based firewall
b) Using TCPD - /etc/hosts.allow and /etc/hosts.deny files

Option b (hosts.allow/hosts.deny) is the easiest to use and supported by all major servers.

Allow incoming packets to tcpd are first matched again hosts.allow and then if there are no matches, they are checked against the rules in hosts.deny file.
Syntax is as follows:
server-name: hostname or ip-address

Where servername can be smbd (samba), sshd (OpenSSH server), sendmail etc.

For example allow sshd access to 192.168.1.1 and 192.168.1.100 IP address only. You need to put following in /etc/hosts.allow file:
Code:
	sshd: 192.168.1.1,192.168.1.100
More example, allow access to all cyberciti.biz hosts (i.e. it will match www.cyberciti.biz, mail.cyberciti.biz etc to ssh):
Code:
sshd: .cyberciti.biz
Allow subnet 192.168.1.0/255.255.255.0 to access sshd:
Code:
              sshd: 192.168.1.0/255.255.255.0
Block telnet to ALL:
Code:
              telnetd: ALL
Block telnet to ALL EXCEPT ip 192.168.1.100
Code:
              telnetd: ALL EXCEPT 192.168.1.100
Read the man page of hosts.allow and hosts.deny for more info.

For option b, (iptables) see following url http://www.cyberciti.biz/faqs/2006/0...nux-server.php
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
MySQL remote server access howto raj Databases servers 0 29-07-2007 05:32 AM
Howto change ip address in Linux chiku Networking, Firewalls and Security 1 29-04-2007 04:51 PM
Static ip address in Ubuntu Linux howto raj Networking, Firewalls and Security 0 18-01-2007 03:18 AM
Sendmail control incoming email to accept, deny, or relay jerry All about FreeBSD/OpenBSD/NetBSD 1 22-06-2006 01:39 PM
Debian recovery mode read only access make it write access Donavit Linux software 1 30-12-2005 12:49 AM


All times are GMT +5.5. The time now is 01:06 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38