How to Disable IPv6


#!/bin/bash

clear
int=$(netstat -i | cut -d” ” -f1 | egrep -v “^Kernel|Iface|lo|:” |head -1)

ip -6 addr show dev $int |cut -b 5-9 >/tmp/ipp

grep “inet6” /tmp/ipp >/dev/null 2>&1 && ip_v=1 || ip_v=0

i6=$(ip addr show dev $int | sed -e’s/^.inet6 ([^ ])\/.*$/\1/;t;d’)
if [ $ip_v -eq 1 ]

then
echo “echo IPv6 found…”;
echo “The IPv6 address is $i6”;
echo “Disabling IPv6 address…”;
echo “net.ipv6.conf.all.disable_ipv6 = 1” >> /etc/sysctl.conf
echo “net.ipv6.conf.default.disable_ipv6 = 1” >> /etc/sysctl.conf
echo “net.ipv6.conf.lo.disable_ipv6 = 1” >> /etc/sysctl.conf
sysctl -p
echo “IPv6 address disable success… :)”
else
echo “IPv6 is already disabled.”

fi

rm -f /tmp/ipp

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s