public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] netfilter: -P INPUT DROP in kernel
@ 2006-04-21 21:41 Daniel Waeber
  2006-04-22 11:41 ` Benno Schulenberg
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Waeber @ 2006-04-21 21:41 UTC (permalink / raw
  To: gentoo-user

[-- Attachment #1: Type: text/plain, Size: 1669 bytes --]

Benno Schulenberg wrote:
 > (By the way, please do not reply to another message when starting a
 > new topic.)
 >
 > Benno

Sorry for that. So I start a new thread now.


 > Daniel Waeber wrote:
 >> I was looking for a way to set the default rule for the INPUT
 >> chain to DROP. I do not want to change the rule with iptables -P
 >> INPUT DROP after loading the kernel, I want that the
 >> kernel/modules automatically DROPS everything after it has been
 >> loaded.
 >> You can do this with the FORWARD chain with the parameter
 >> forward=0, but nothing is implemented for the INPUT chain as far
 >> as i know. I looked inside the kernel source of the modules, and
 >> hey, it is easy to change. I recompiled the module, reloaded it.
 >> Perfect, now i have default DROP.
 >> But as it is so easy to edit, why is there no option in the
 >> kernel or a parameter for the module
 >
 > Make a patch that adds this parameter, allowing one to set the
 > default policy for the input chain (and output chain too), and
 > submit it to the kernel list.  Or show it here first.  I'd be
 > interested.

Because I'm new to Linux, this is my first patch, so i don't know if 
everything is done right. Perhaps someone can examine it before I send 
it to kernel.org. I added code so you can pass the parameter "input=0" 
and "output=0" to the iptable_filter module to change the policies. It's 
the same code already implemented for the forward chain, which can be 
set to 0 to drop, 1 to accept.
I don't now if how/if this parameter can be passed, if netfilter is 
build inside the kernel, so perhaps this is not the perfect solution.

Have fun with a default denying firewall :)

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1603 bytes --]

diff -upr linux-2.6.16-gentoo-r3/net/ipv4/netfilter/iptable_filter.c netfilter_dorp_patch_linux/net/ipv4/netfilter/iptable_filter.c
--- linux-2.6.16-gentoo-r3/net/ipv4/netfilter/iptable_filter.c	2006-04-21 22:51:05.000000000 +0200
+++ netfilter_dorp_patch_linux/net/ipv4/netfilter/iptable_filter.c	2006-04-21 22:38:07.000000000 +0200
@@ -135,21 +135,45 @@ static struct nf_hook_ops ipt_ops[] = {
 	},
 };
 
-/* Default to forward because I got too much mail already. */
+/* Default options for the kernel module */
+/* As default everything is accepted */
+static int input = NF_ACCEPT;
+module_param(input, bool, 0000);
+
 static int forward = NF_ACCEPT;
 module_param(forward, bool, 0000);
 
+static int output = NF_ACCEPT;
+module_param(output, bool, 0000);
+
+
+
 static int __init init(void)
 {
 	int ret;
 
+	if (input < 0 || input > NF_MAX_VERDICT ) {
+		printk("iptables input must be 0 or 1\n");
+		return -EINVAL;
+	}
 	if (forward < 0 || forward > NF_MAX_VERDICT) {
 		printk("iptables forward must be 0 or 1\n");
 		return -EINVAL;
 	}
+	if (output < 0 || output > NF_MAX_VERDICT) {
+		printk("iptables output must be 0 or 1\n");
+		return -EINVAL;
+	}
 
+	/* Set the default policys according to the module parameters */
+	/* Entry 0 is the INPUT hook */
+	initial_table.entries[0].target.verdict = -input -1;	
 	/* Entry 1 is the FORWARD hook */
 	initial_table.entries[1].target.verdict = -forward - 1;
+	/* Entry 2 is the OUTPUT hook */
+	initial_table.entries[2].target.verdict = -output -1;
+
+
 
 	/* Register table */
 	ret = ipt_register_table(&packet_filter, &initial_table.repl);

^ permalink raw reply	[flat|nested] 4+ messages in thread
* [gentoo-user] OT - openssh and ldap
@ 2006-04-20 21:31 Michael Sullivan
  2006-04-21  0:00 ` [gentoo-user] netfilter: -P INPUT DROP in kernel Daniel Waeber
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Sullivan @ 2006-04-20 21:31 UTC (permalink / raw
  To: gentoo-user

I rebooted my server box this morning.  On a few of the output lines
during bootup (noteably sshd and mysqld) it said "Could not connect to
LDAP server" (or something like that).  To my knowledge, I don't have an
ldap server installed on my server box.  Ssh from client machines is
extremely slow to connect.  I checked eix -SS ldap and the only ldap
package I have installed on the server box is openldap.  I
checked /etc/make.conf to ensure that ldap was not listed as a USE flag,
and then typed "emerge -pv openssh"  Here's the output:  

bullet etc # emerge -av openssh

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild   R   ] net-misc/openssh-4.3_p2-r1  -X509 -chroot -hpn -ipv6
+kerberos +ldap -libedit +pam (-selinux) -sftplogging -skey -smartcard
-static +tcpd 0 kB

Is there any danger in me adding "net-misc/openssh -ldap"
to /etc/portage/package.use?  Will it speed up the connection process?
It was never a problem until today...

-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-04-22 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-21 21:41 [gentoo-user] netfilter: -P INPUT DROP in kernel Daniel Waeber
2006-04-22 11:41 ` Benno Schulenberg
  -- strict thread matches above, loose matches on Subject: below --
2006-04-20 21:31 [gentoo-user] OT - openssh and ldap Michael Sullivan
2006-04-21  0:00 ` [gentoo-user] netfilter: -P INPUT DROP in kernel Daniel Waeber
2006-04-21 19:36   ` Benno Schulenberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox