blob: 431a4272223e21a500233100a9378fd4ca38f90e [file] [log] [blame]
#!/bin/bash
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
ip6tables -P INPUT DROP -w
ip6tables -P FORWARD DROP -w
ip6tables -P OUTPUT DROP -w
# Accept everything on the loopback
ip6tables -A INPUT -i lo -j ACCEPT -w
ip6tables -A OUTPUT -o lo -j ACCEPT -w
# Accept all inbound TCP/UDP/ICMP/SCTP packets
ip6tables -A INPUT -p tcp -j ACCEPT -w
ip6tables -A INPUT -p udp -j ACCEPT -w
ip6tables -A INPUT -p icmpv6 -j ACCEPT -w
ip6tables -A INPUT -p sctp -j ACCEPT -w
# Accept all forwarded TCP/UDP/ICMP/SCTP packets
ip6tables -A FORWARD -p tcp -j ACCEPT -w
ip6tables -A FORWARD -p udp -j ACCEPT -w
ip6tables -A FORWARD -p icmpv6 -j ACCEPT -w
ip6tables -A FORWARD -p sctp -j ACCEPT -w
ip6tables -A OUTPUT -p icmpv6 -j ACCEPT -w
# Accept return traffic inbound
ip6tables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -w
# Accept new and return traffic outbound
ip6tables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT -w
# Allow DHCPv6 client inbound
ip6tables -A INPUT -p udp -m udp --dport 546 -j ACCEPT