Skip to content

Instantly share code, notes, and snippets.

@pocki80 pocki80/load_ipv6_hostsfile.sh Secret

Last active Dec 5, 2018
Embed
What would you like to do?
load_ipv6_hostsfile
#!/bin/bash
# load ipv6 hostnames to local /etc/hosts
#
# UPDATE via CLI:
# curl -sS https://gist.githubusercontent.com/pocki80/fc6ede395e04dde62ce2199a8281261f/raw/load_ipv6_hostsfile.sh | sudo bash
curl -sS http://193.238.158.8/0xFF-BMK-webstatus/hosts_originators.txt | grep "funkfeuer.at=" | awk -F"=" '{printf "%-40s %s\n", $2,$3}' >/tmp/hostfile
curl -sS http://193.238.158.8/0xFF-BMK-webstatus/642.txt | awk -F"," '{printf "%-40s 642endpoint.%s.wien.funkfeuer.at\n", $1,$2}' >>/tmp/hostfile
if [ $(cat /tmp/hostfile | wc -l ) \> 10 ]; then
(grep -q "#hostoriginator_begin" /etc/hosts) && sed -i '/^#hostoriginator_begin/,/^#hostoriginator_end\n$/d' /etc/hosts || echo "" >>/etc/hosts
echo "#hostoriginator_begin ($(date))
$(cat /tmp/hostfile)
$(echo "#additional entries
2a02:61:0:ff:822a:a8ff:fe5f:7b05 router.2355RIAG.wien.funkfeuer.at
2a02:61:b9d::1 tunnel6.funkfeuer.at
2a02:60:10b:9c21::1 v33-mesh.ts2018.funkfeuer.at
2a02:60:1:100::ffff bmk-rt-02-outside.funkfeuer.at
2a02:60:1:103::1 bmk-rt-02-inside.funkfeuer.at
2a02:61:0:ff:618:d6ff:fef0:b19e usg-outside.wehr24.wien.funkfeuer.at
2a02:61:a9e:f140::1 usg-inside.wehr24.wien.funkfeuer.at
2a02:60:35:492:1:e:0:2 ge1-519-ts2018.funkfeuer.at
2a02:60:35:492:1:f:0:2 ge1-520-ts2018.funkfeuer.at
2a02:60:35:492:1:e:0:1 ten2-519-r01krypta.bb.funkfeuer.at
2a02:60:35:492:1:f:0:1 ten2-520-r01nessus.bb.funkfeuer.at
2a02:60:35:492:1:5:0:1 ten2-503-r01nessus.bb.funkfeuer.at
2a02:60:35:492:1:9:0:1 ten2-506-r01krypta.bb.funkfeuer.at
2a00:11c0:47:3::2a funkfeuer-peer.bbr01.anx04.vie.at.anexia-it.net
2a00:11c0:47:3::2b ten2-518-r01krypta.bb.funkfeuer.at
2a01:190:1701::9 ten2-221-r01krypta.bb.funkfeuer.at
2a01:190:1701::a funkfeuer-peer.inx.vie.at.nextlayer.net
144.208.211.57 ten2-518-r01krypta.bb.funkfeuer.at
144.208.211.56 funkfeuer-peer.bbr01.anx04.vie.at.anexia-it.net
81.16.148.145 funkfeuer-peer.inx.vie.at.nextlayer.net
81.16.148.146 ten2-221-r01krypta.bb.funkfeuer.at
")
#hostoriginator_end
" >>/etc/hosts
fi
rm /tmp/hostfile
echo "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.