Created
April 6, 2018 08:18
-
-
Save borgle/dd5d64825275965aec07ad19a0663540 to your computer and use it in GitHub Desktop.
A shell for vultr private network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
private_network() { | |
local PRIVATE_IP=$1 | |
if [ -f '/etc/sysconfig/network-scripts/ifcfg-eth1' ] | |
then | |
ifdown eth1 > /dev/null 2>&1 | |
fi | |
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-eth1 | |
DEVICE=eth1 | |
ONBOOT=yes | |
BOOTPROTO=static | |
IPADDR=$PRIVATE_IP | |
NETMASK=255.255.255.0 | |
MTU=1450 | |
EOF | |
ifup eth1 | |
} | |
private_network 10.99.0.188 | |
ip="10.99.0." | |
for i in `seq 10 100` | |
do | |
ping -c 2 $ip$i | grep -q 'ttl=' > /dev/null | |
if [ $? -eq 1 ] | |
then | |
private_network $ip$i | |
echo "New private ip: $ip$i" | |
break | |
else | |
echo "$ip$i exists" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment