Skip to contentSkip to conversation

Double stack IPv4&&IPv6 for a firewall

DISCUSSION Arturo Borrero 5 participants 10 messages Aug 24, 2012 – Aug 28, 2012 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hi there!

The way is recommended to implement IPv6 in a network while IPv4 is still alive is double stack. In a network where all have DNS records, double stack means that each FQDN has an A reg. and an AAAA reg.

So, deploying a DNS-based firewall takes you to duplicate the ruleset, first for iptables/ip6tables and then for ipset family inet/ipset family inet6

The question is:

Do anyone knows a program, framework, script, method or whatever to face this situation?

I'm talking of an 'abstraction' method that hides the differences between iptables/ip6tables, as long as is using almost always FQDNs with both DNS regs to configure the ruleset.

Best regards.

Signature · 7 lines
Arturo Borrero González
Departamento de Seguridad Informática, @NIS_CICA (twitter)
Centro Informático Científico de Andalucía (CICA)
Avda. Reina Mercedes s/n - 41012 - Sevilla (Spain)
Tfno.: +34 955 056 600 / FAX: +34 955 056 650
Consejería de Economía, Innovación, Ciencia y Empleo
Junta de Andalucía
#1 lore raw
Quoted 13 lines · Arturo Borrero

Hi there!

The way is recommended to implement IPv6 in a network while IPv4 is still alive is double stack.
In a network where all have DNS records, double stack means that each FQDN has an A reg. and an AAAA reg.

So, deploying a DNS-based firewall takes you to duplicate the ruleset, first for iptables/ip6tables and then for ipset family inet/ipset family inet6

The question is:

Quoted 10 lines

Do anyone knows a program, framework, script, method or whatever to face this situation?

I'm talking of an 'abstraction' method that hides the differences between iptables/ip6tables, as long as is using almost always FQDNs with both DNS regs to configure the ruleset.

Best regards.

Hmm . . . perhaps it has changed but, when I investigated it years ago, using FQDNs for iptables rules was problematic in that the names were only resolved at the time the rules were loaded. If any of the addresses change, the firewall is completely unaware of the change as it does not resolve the name on each query. Is that still the case? - John

#2 lore raw
Quoted 21 lines · John A. Sullivan III
Quoted 20 lines · Arturo Borrero

Hi there!

The way is recommended to implement IPv6 in a network while IPv4 is still alive is double stack.
In a network where all have DNS records, double stack means that each FQDN has an A reg. and an AAAA reg.

So, deploying a DNS-based firewall takes you to duplicate the ruleset, first for iptables/ip6tables and then for ipset family inet/ipset family inet6

The question is:

Do anyone knows a program, framework, script, method or whatever to face this situation?

I'm talking of an 'abstraction' method that hides the differences between iptables/ip6tables, as long as is using almost always FQDNs with both DNS regs to configure the ruleset.

Quoted 8 lines
Quoted 3 lines

Best regards.

Hmm . . . perhaps it has changed but, when I investigated it years ago, using FQDNs for iptables rules was problematic in that the names were only resolved at the time the rules were loaded. If any of the addresses change, the firewall is completely unaware of the change as it does not resolve the name on each query. Is that still the case? - John

Naturally, since DNS lookups will introduce a shitload of latency and error potential (like, when DNS itself fails) were it done for every packet.

A message that is not in the archive (sent off-list or not yet received): CAPfcJatemcsT5PK+m8__xhB7gBRinAuq2wNX_g93CQrSmvtDhQ@mail.gmail.com

#4 lore raw
Quoted 3 lines · Arturo Borrero

DNS lookups are a problem in a big ruleset (~10.000) rules, so the point is to do some kind of local cache.

So run a local BIND server, lwresd, dnsmasq, nscd, or whatever.

Quoted 1 line

As I supposed, the doble stack method is not being well aproached yet.

What isn't?

Quoted 2 lines

The code (bash) is here:
https://github.com/aborrero/fw-admin

sh is amongst the *slowest* of all. Your README.md says

Quoted 4 lines

You usally set your ruleset in this way:

$IPT -A INPUT -i $IF -s $INTERNET -d $MYSERVER -p tcp --sport 1024: --dport $SSH_PORT -j ACCEPT

If you begin with something like this, no wonder it's all going slow, because you are needlessy reloading all the damn rules. That's why smart people use iptables-restore.

Also, the --sport 1024: is pretty dull, because there is no RFC that forbids the use of numbers lower than that.

Quoted 1 line

Also, fw-admin is just a complex bash script

Its greatest problem, btw.

#5 lore raw
Quoted 4 lines · Jan Engelhardt
Quoted 2 lines · Arturo Borrero

You usally set your ruleset in this way:

Quoted 8 lines
Quoted 3 lines

$IPT -A INPUT -i $IF -s $INTERNET -d $MYSERVER -p tcp --sport 1024:
--dport
$SSH_PORT -j ACCEPT

If you begin with something like this, no wonder it's all going slow, because you are needlessy reloading all the damn rules. That's why smart people use iptables-restore.

Oh, only about ~2000 times faster in my tests :p
http://www.slideshare.net/slideshow/embed_code/14051936?startSlide=22

Signature · 1 line
Julien Vehent - http://jve.linuxwal.info

A message that is not in the archive (sent off-list or not yet received): CAPfcJaugwb5DboUYGAfEktHCDZX0KxdCWdS9CyAu3rh94P8inQ@mail.gmail.com

#7 lore raw
Quoted 9 lines · Jan Engelhardt
Quoted 8 lines · Arturo Borrero
Quoted 6 lines

You usally set your ruleset in this way:

$IPT -A INPUT -i $IF -s $INTERNET -d $MYSERVER -p tcp --sport 1024:
--dport
$SSH_PORT -j ACCEPT

Quoted 7 lines
Quoted 4 lines

If you begin with something like this, no wonder it's all going slow, because you are needlessy reloading all the damn rules. That's why smart people use iptables-restore.

Oh, only about ~2000 times faster in my tests :p
http://www.slideshare.net/slideshow/embed_code/14051936?startSlide=22

Well, but the problem of writting two different rulesets with the same info is still unsolved.

And If you permit my point of view, I think it's harder to solve using iptables-restore than using bash and iptables/ip6tables (because variables, additional flexibility of bash, etc...)

Maybe the point would be to generate with Bash a iptables-restore ruleset to load to kernel, but not load the ruleset directly from Bash...

--
Arturo Borrero González
Departamento de Seguridad Informática, @NIS_CICA (twitter) Centro Informatico Cientifico de Andalucia (CICA) Avda. Reina Mercedes s/n - 41012 - Sevilla (Spain) Tfno.: +34 955 056 600 / FAX: +34 955 056 650 Consejería de Economía, Innovación, Ciencia y Empleo Junta de Andalucía

#8 lore raw
Quoted 5 lines · Arturo Borrero

Maybe the point would be to generate with Bash a iptables-restore ruleset to load to kernel, but not load the ruleset directly from Bash...

Correct. The syntax of iptables-restore is similar to the one of iptables, with the addition of the ordering that needs to be respected. Then, simply issue iptables-restore < /path/to/ruleset.

- Julien

#9 lore raw
In reply to Arturo Borrero
Quoted 16 lines · Arturo Borrero
Quoted 7 lines · Jan Engelhardt
Quoted 6 lines · Arturo Borrero
Quoted 5 lines

You usally set your ruleset in this way:

$IPT -A INPUT -i $IF -s $INTERNET -d $MYSERVER -p tcp --sport 1024:
--dport
$SSH_PORT -j ACCEPT

Quoted 6 lines
Quoted 4 lines

If you begin with something like this, no wonder it's all going slow, because you are needlessy reloading all the damn rules. That's why smart people use iptables-restore.

Oh, only about ~2000 times faster in my tests :p
http://www.slideshare.net/slideshow/embed_code/14051936?startSlide=22

Well, but the problem of writting two different rulesets with the same info is still unsolved.

Quoted 7 lines

And If you permit my point of view, I think it's harder to solve using iptables-restore than using bash and iptables/ip6tables (because variables, additional flexibility of bash, etc...)

Maybe the point would be to generate with Bash a iptables-restore ruleset to load to kernel, but not load the ruleset directly from Bash...

I use a wrapper generator called "ferm". It generates the iptables/ip6tables once with a lot of flexibility, then uses iptables-save/restore to operate the system.

AYJ

#10 lore raw
Quoted 1 line · Amos Jeffries

I use a wrapper generator called "ferm". It generates the iptables/ip6tables once with a lot of flexibility, then uses iptables-save/restore to operate the system.

Reading `ferm' documentation, it seems that the original issue is still latent:

domain [ip|ip6]

You have yo choose one of the two keywords, what forces you to write the firewall twice.

Or i'm wrong?

Signature · 7 lines
Arturo Borrero González
Departamento de Seguridad Informática, @NIS_CICA (twitter)
Centro Informático Científico de Andalucía (CICA)
Avda. Reina Mercedes s/n - 41012 - Sevilla (Spain)
Tfno.: +34 955 056 600 / FAX: +34 955 056 650
Consejería de Economía, Innovación, Ciencia y Empleo
Junta de Andalucía
#11 lore raw
Quoted 11 lines · Arturo Borrero
Quoted 1 line · Amos Jeffries

I use a wrapper generator called "ferm". It generates the iptables/ip6tables once with a lot of flexibility, then uses iptables-save/restore to operate the system.

Reading `ferm' documentation, it seems that the original issue is still latent:

domain [ip|ip6]

You have yo choose one of the two keywords, what forces you to write the firewall twice.

Or i'm wrong?

If you wish you can write "domain (ip ip6) { .. } ". which expands the .. rules list for both.

AYJ