From 339a3569445707e05af8e88a281d652221adbac7 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Mon, 13 Feb 2017 19:50:44 +0100 Subject: [PATCH] On garde une IP fixe, c'est mieux --- sub_scripts/lxc_build.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sub_scripts/lxc_build.sh b/sub_scripts/lxc_build.sh index dfaf66b..50dddef 100755 --- a/sub_scripts/lxc_build.sh +++ b/sub_scripts/lxc_build.sh @@ -70,8 +70,8 @@ sudo ifup $LXC_BRIDGE --interfaces=/etc/network/interfaces.d/$LXC_BRIDGE >> "$LO echo -e "\e[1m> Configuration réseau du conteneur\e[0m" | tee -a "$LOG_BUILD_LXC" sudo sed -i "s/^lxc.network.type = empty$/lxc.network.type = veth\nlxc.network.flags = up\nlxc.network.link = $LXC_BRIDGE\nlxc.network.name = eth0\nlxc.network.hwaddr = 00:FF:AA:00:00:01/" /var/lib/lxc/$LXC_NAME/config >> "$LOG_BUILD_LXC" 2>&1 -# echo -e "\e[1m> Configuration réseau de la machine virtualisée\e[0m" | tee -a "$LOG_BUILD_LXC" -# sudo sed -i "s@iface eth0 inet dhcp@iface eth0 inet static\n\taddress $PLAGE_IP.2/24\n\tgateway $PLAGE_IP.1@" /var/lib/lxc/$LXC_NAME/rootfs/etc/network/interfaces >> "$LOG_BUILD_LXC" 2>&1 +echo -e "\e[1m> Configuration réseau de la machine virtualisée\e[0m" | tee -a "$LOG_BUILD_LXC" +sudo sed -i "s@iface eth0 inet dhcp@iface eth0 inet static\n\taddress $PLAGE_IP.2/24\n\tgateway $PLAGE_IP.1@" /var/lib/lxc/$LXC_NAME/rootfs/etc/network/interfaces >> "$LOG_BUILD_LXC" 2>&1 echo -e "\e[1m> Configure le parefeu\e[0m" | tee -a "$LOG_BUILD_LXC" sudo iptables -A FORWARD -i $LXC_BRIDGE -o $main_iface -j ACCEPT >> "$LOG_BUILD_LXC" 2>&1 @@ -86,9 +86,6 @@ sudo lxc-ls -f >> "$LOG_BUILD_LXC" 2>&1 echo -e "\e[1m> On lance l'interface réseau\e[0m" | tee -a "$LOG_BUILD_LXC" sudo lxc-attach -n $LXC_NAME -- /etc/init.d/networking start -echo -e "\e[1m> On récupére l'ip du container\e[0m" | tee -a "$LOG_BUILD_LXC" -IP_CONTAINER=$(sudo lxc-attach -n $LXC_NAME -- ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') - echo -e "\e[1m> Update et install aptitude sudo git\e[0m" | tee -a "$LOG_BUILD_LXC" sudo lxc-attach -n $LXC_NAME -- apt-get update sudo lxc-attach -n $LXC_NAME -- apt-get install -y aptitude sudo git @@ -117,7 +114,7 @@ sudo lxc-attach -n $LXC_NAME -- chown pchecker: -R /home/pchecker/.ssh >> "$LOG_ echo | tee -a $HOME/.ssh/config <> "$LOG_BUILD_LXC" 2>&1 # ssh $LXC_NAME Host $LXC_NAME -Hostname $IP_CONTAINER +Hostname $PLAGE_IP.2 User pchecker IdentityFile $HOME/.ssh/$LXC_NAME EOF