Networking Forums

Networking Forums > Computer Networking > Linux Networking > HELP, Need quick iptables rules

Reply
Thread Tools Display Modes

HELP, Need quick iptables rules

 
 
akak01000101@gmail.com
Guest
Posts: n/a

 
      01-15-2008, 07:18 AM

I'm a newbie to iptables and need quick iptables rules that say any
node can connect inbound to the linux server from subnets
192.168.1.0/24 and 192.168.2.0/24 to port 8000 via TCP, and deny all
other networks.

Any help is greatly appreciated! Thanks...

-akak
 
Reply With Quote
 
 
 
 
Ashish Shukla आशीष शुक्ल
Guest
Posts: n/a

 
      01-15-2008, 12:49 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>>> On Tue, 15 Jan 2008 00:18:45 -0800 (PST), (E-Mail Removed) said:


akak01000101> I'm a newbie to iptables and need quick iptables rules that say any
akak01000101> node can connect inbound to the linux server from subnets
akak01000101> 192.168.1.0/24 and 192.168.2.0/24 to port 8000 via TCP, and deny all
akak01000101> other networks.

/sbin/iptables -A INPUT --src-host 192.168.1.0/24 -p tcp --dport 8000 -j ACCEPT
/sbin/iptables -A INPUT --src-host 192.168.2.0/24 -p tcp --dport 8000 -j ACCEPT

HTH
- --
Ashish Shukla आशीष शुक्ल http://wahjava.wordpress.com/
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHjLoOHy+EEHYuXnQRAhTsAJ9+2Tp/KGOpYl/KNBTfBly68LcAQACglbAK
lBQEpPD39f/OhQvnO/CL6ow=
=H2gN
-----END PGP SIGNATURE-----
 
Reply With Quote
 
Ashish Shukla आशीष शुक्ल
Guest
Posts: n/a

 
      01-15-2008, 02:24 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>>> "आशीष" == Ashish Shukla आशीष शुक्ल <(E-Mail Removed)> writes:
>>>>> On Tue, 15 Jan 2008 00:18:45 -0800 (PST), (E-Mail Removed) said:


akak01000101> I'm a newbie to iptables and need quick iptables rules that say any
akak01000101> node can connect inbound to the linux server from subnets
akak01000101> 192.168.1.0/24 and 192.168.2.0/24 to port 8000 via TCP, and deny all
akak01000101> other networks.

Forgot to mention deny rule.

आशीष> /sbin/iptables -A INPUT --src-host 192.168.1.0/24 -p tcp --dport 8000 -j ACCEPT
आशीष> /sbin/iptables -A INPUT --src-host 192.168.2.0/24 -p tcp --dport 8000 -j ACCEPT

/sbin/iptables -A INPUT -p tcp --dport 8000 -j DROP

HTH
- --
Ashish Shukla आशीष शुक्ल http://wahjava.wordpress.com/
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHjNAqHy+EEHYuXnQRAiFuAJ49WXX7YIqiEVLKDhIk8V qVtJ1oIgCgupD5
onFhmfXFu/gZIV//0MSGkEk=
=tIk1
-----END PGP SIGNATURE-----
 
Reply With Quote
 
habibielwa7id
Guest
Posts: n/a

 
      01-16-2008, 08:08 AM
On Jan 15, 5:24 pm, wahj...@gmail.com (Ashish Shukla आशीष शुक्ल)
wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> >>>>> "आशीष" == Ashish Shukla आशीष शुक्ल<wahj...@gmail.com> writes:
> >>>>> On Tue, 15 Jan 2008 00:18:45 -0800 (PST), akak01000...@gmail.com said:

>
> akak01000101> I'm a newbie to iptables and need quick iptables rules that say any
> akak01000101> node can connect inbound to the linux server from subnets
> akak01000101> 192.168.1.0/24 and 192.168.2.0/24 to port 8000 via TCP, and deny all
> akak01000101> other networks.
>
> Forgot to mention deny rule.
>
> आशीष> /sbin/iptables -A INPUT --src-host 192.168.1.0/24 -p tcp --dport 8000 -j ACCEPT
> आशीष> /sbin/iptables -A INPUT --src-host 192.168.2.0/24 -p tcp --dport 8000 -j ACCEPT
>
> /sbin/iptables -A INPUT -p tcp --dport 8000 -j DROP
>
> HTH
> - --
> Ashish Shukla आशीष शुक्ल http://wahjava.wordpress.com/
> ·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFHjNAqHy+EEHYuXnQRAiFuAJ49WXX7YIqiEVLKDhIk8V qVtJ1oIgCgupD5
> onFhmfXFu/gZIV//0MSGkEk=
> =tIk1
> -----END PGP SIGNATURE-----


-But be careful where to put these rules. they may not work if there
any other rules before them may block the traffic for example,so
beware,and you may input them as first rules so no other earlier rule
can affect them. So some times don't use -A and use -I with arule
number like
/sbin/iptables -I INPUT 1 -s 192.168.1.0/24 -p tcp --dport 8000 -j
ACCEPT
/sbin/iptables -I INPUT 2 -s 192.168.2.0/24 -p tcp --dport 8000 -j
ACCEPT
/sbin/iptables -I INPUT 3 -p tcp --dport 8000 -j DROP
And then don't forget to store the new rules you added. So you don't
lose them when you restart your system.
wishes
 
Reply With Quote
 
Matthew Shelton
Guest
Posts: n/a

 
      02-02-2008, 02:04 PM
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

(E-Mail Removed) wrote:
| I'm a newbie to iptables and need quick iptables rules that say any
| node can connect inbound to the linux server from subnets
| 192.168.1.0/24 and 192.168.2.0/24 to port 8000 via TCP, and deny all
| other networks.
|
| Any help is greatly appreciated! Thanks...
|
| -akak

Another word of advice, when you're configuring the firewall. Don't try
to ssh to the firewall box you're trying to configure. As previously
mentioned, you can lockdown the entire computer accidentally, which
boots your ssh session in the process.

a misplaced "iptables -P INPUT DROP" can really fuck your day.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHpIZx9v5kFOkJa9gRAm35AJ9Sb+32TpiuzSOJSEKje1 6YjKCMdACgiNi1
y3PY4/BPufJL6FFjcIgcbXY=
=g6Z+
-----END PGP SIGNATURE-----

 
Reply With Quote
 
D. Stussy
Guest
Posts: n/a

 
      03-03-2008, 07:45 PM
"habibielwa7id" <(E-Mail Removed)> wrote in message
news:b3e861dc-ef7e-4dfa-a94d-(E-Mail Removed)...
On Jan 15, 5:24 pm, wahj...@gmail.com (Ashish Shukla ???? ?????)
wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> >>>>> "????" == Ashish Shukla ???? ????? <wahj...@gmail.com> writes:
> >>>>> On Tue, 15 Jan 2008 00:18:45 -0800 (PST), akak01000...@gmail.com

said:
>
> akak01000101> I'm a newbie to iptables and need quick iptables rules

that say any
> akak01000101> node can connect inbound to the linux server from

subnets
> akak01000101> 192.168.1.0/24 and 192.168.2.0/24 to port 8000 via TCP,

and deny all
> akak01000101> other networks.
>
> Forgot to mention deny rule.
>
> ????> /sbin/iptables -A INPUT --src-host 192.168.1.0/24 -p tcp --dport

8000 -j ACCEPT
> ????> /sbin/iptables -A INPUT --src-host 192.168.2.0/24 -p tcp --dport

8000 -j ACCEPT

Athough the "-p tcp" selects the TCP protocol, don't you also need a "-m
tcp" in order to be able to use the "--dport" option?

> /sbin/iptables -A INPUT -p tcp --dport 8000 -j DROP
>
> HTH


The same question goes for the reply below too:

-But be careful where to put these rules. they may not work if there
any other rules before them may block the traffic for example,so
beware,and you may input them as first rules so no other earlier rule
can affect them. So some times don't use -A and use -I with arule
number like
/sbin/iptables -I INPUT 1 -s 192.168.1.0/24 -p tcp --dport 8000 -j
ACCEPT
/sbin/iptables -I INPUT 2 -s 192.168.2.0/24 -p tcp --dport 8000 -j
ACCEPT
/sbin/iptables -I INPUT 3 -p tcp --dport 8000 -j DROP
And then don't forget to store the new rules you added. So you don't
lose them when you restart your system.
wishes


 
Reply With Quote
 
 
 
Reply

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
Iptables: rules not applied? julien Linux Networking 2 08-03-2008 05:05 PM
Removing iptables rules Augustus SFX van Dusen Linux Networking 7 06-05-2006 04:05 PM
Iptables and rules from database ? snowi@ras.pl Linux Networking 0 10-16-2005 11:20 AM
Looking for iptables applications code (iptables.c) to run some rules to forward packets tvnaidu@yahoo.com Linux Networking 2 01-17-2005 05:01 PM
iptables rules for vonage Rob Ristroph Linux Networking 0 10-02-2003 06:44 AM



1 2 3 4 5 6 7 8 9 10 11