I would like to set up a firewall on Linux Debian for IPv6. It is important to use iptables for me. I have tried to change the ipv4 folder to ipv6.

enter image description here

How can I set up iptables for IPv6?

  • 1
    What's the problem with just replacing iptables with ip6tables? – Braiam May 7 '15 at 20:13
  • Just one thing: I don't know how can do it? – blackcornail May 7 '15 at 20:15
  • Did you read ip6tables man page? – Braiam May 7 '15 at 20:17
  • 4
    @blackcornail: btw, it would be highly beneficial for anyone searching the web if you replaced your screenshot by an actual preformatted paragraph with the script contents. – 0xC0000022L May 7 '15 at 20:40
  • 2
    @blackcornail Not sure if you or anyone else noticed. You've a syntax error there in your start) section. iptables -nat -A ... should be iptables -t nat -A ... – Valentin Bajrami May 7 '15 at 21:10

In addition to the existing answer.

If you prefer (like I do) to use the syntax from the iptables-save and iptables-restore command ip6tables-save and ip6tables-restore can be used.

The convenient part is that you can share the same rule file for iptables-restore and ip6tables-restore respectively by prefixing all the version-specific lines with -4 and -6 respectively and leaving it out on lines that apply to both IPv4 and IPv6.

In order to to check for the correct address family ($ADDRFAM) in your script, use:

set -e
case "$1" in
  case $ADDRFAM in
  inet)  iptables-restore  < /etc/myfwrules.txt ;;
  inet6) ip6tables-restore < /etc/myfwrules.txt ;;
  # ...
  # ...
exit 0

Just use the command ip6tables instead of iptables. In most (all?) ways that matter, it works the same.


You have to use ip6tables instead of iptables And the foolowing command is available :

ip6tables-restore and ip6tables-save

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.