nixCraft Linux Forum

nixCraft

Linux 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

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 07-08-2006, 02:36 AM
Junior Member
 
Join Date: Jul 2005
Posts: 4
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
Sponsored Links
  #2 (permalink)  
Old 07-10-2006, 08:44 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,034
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, (iptable see following url http://www.cyberciti.biz/faqs/2006/0...nux-server.php
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


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 On

Similar Threads

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


All times are GMT +5.5. The time now is 02:47 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

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