From 84cbe3c94df038b7d1c5084304222b059d0c385d Mon Sep 17 00:00:00 2001
From: Sebastian Rieger <sebastian.rieger@informatik.hs-fulda.de>
Date: Fri, 16 Dec 2016 16:20:34 +0100
Subject: [PATCH] added webserver, port forwarding an unbug commands

---
 .../kommprot-lab3-wanem.virl                  | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/GIT-VIRL-HS-Fulda/Kommunikationsnetze und -protokolle (Bachelor AI)/kommprot-lab3-wanem.virl b/GIT-VIRL-HS-Fulda/Kommunikationsnetze und -protokolle (Bachelor AI)/kommprot-lab3-wanem.virl
index 4a36680..9bab321 100644
--- a/GIT-VIRL-HS-Fulda/Kommunikationsnetze und -protokolle (Bachelor AI)/kommprot-lab3-wanem.virl	
+++ b/GIT-VIRL-HS-Fulda/Kommunikationsnetze und -protokolle (Bachelor AI)/kommprot-lab3-wanem.virl	
@@ -298,7 +298,7 @@ end
         <interface id="1" name="GigabitEthernet0/2"/>
         <interface id="2" name="GigabitEthernet0/3"/>
     </node>
-    <node name="Client" type="SIMPLE" subtype="lxc" location="186,310">
+    <node name="Client" type="SIMPLE" subtype="lxc" location="154,308">
         <extensions>
             <entry key="Auto-generate config" type="Boolean">false</entry>
             <entry key="config" type="String">#cloud-config&#xD;
@@ -356,6 +356,7 @@ write_files:&#xD;
     route del default&#xD;
     route add default gw 192.168.1.1&#xD;
     arp -i eth1 -s 192.168.1.1 aa:aa:aa:aa:aa:aa&#xD;
+    echo "alias unbug='sudo arp -d 192.168.1.1'" &gt;&gt;/home/cisco/.bashrc&#xD;
     exit 0&#xD;
 &#xD;
 - path: /etc/resolv.conf&#xD;
@@ -370,6 +371,7 @@ write_files:&#xD;
     </node>
     <node name="ISP" type="SIMPLE" subtype="lxc" location="343,149">
         <extensions>
+            <entry key="Auto-generate config" type="Boolean">false</entry>
             <entry key="config" type="String">#cloud-config&#xD;
 bootcmd:&#xD;
 - ln -s -t /etc/rc.d /etc/rc.local&#xD;
@@ -440,8 +442,13 @@ write_files:&#xD;
      iptables -t nat -A POSTROUTING -o eth3 -j MASQUERADE&#xD;
      iptables -P FORWARD ACCEPT&#xD;
      iptables -F FORWARD&#xD;
+&#xD;
+     iptables -t nat -A PREROUTING -i eth3 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.2.100:80&#xD;
+     iptables -t nat -A PREROUTING -i eth3 -p tcp -m tcp --dport 22 -j DNAT --to-destination 192.168.2.100:22&#xD;
 &#xD;
      /sbin/tc qdisc add dev eth2 root handle 1:1 netem delay 100ms loss 5%&#xD;
+     echo "alias unbug='sudo tc qdisc del dev eth2 root'" &gt;&gt;/home/cisco/.bashrc&#xD;
+&#xD;
      service ssh start&#xD;
     &#xD;
      hostname ISP&#xD;
@@ -449,7 +456,6 @@ write_files:&#xD;
       exit 0&#xD;
 &#xD;
 </entry>
-            <entry key="Auto-generate config" type="Boolean">false</entry>
         </extensions>
         <interface id="0" name="eth1"/>
         <interface id="1" name="eth2"/>
@@ -468,6 +474,7 @@ runcmd:&#xD;
 - start ttyS0&#xD;
 - systemctl start getty@ttyS0.service&#xD;
 - systemctl start rc-local&#xD;
+- systemctl start install-webserver&#xD;
 - sed -i '/^\s*PasswordAuthentication\s\+no/d' /etc/ssh/sshd_config&#xD;
 - echo "UseDNS no" &gt;&gt; /etc/ssh/sshd_config&#xD;
 - service ssh restart&#xD;
@@ -513,7 +520,22 @@ write_files:&#xD;
     ifconfig eth1 up 192.168.2.100 netmask 255.255.255.0&#xD;
     route del default&#xD;
     route add default gw 192.168.2.1&#xD;
+    route add -net 192.168.1.0/24 gw 127.0.0.1&#xD;
+    echo "alias unbug='sudo route del -net 192.168.1.0/24'" &gt;&gt;/home/cisco/.bashrc&#xD;
     echo "nameserver 8.8.8.8" &gt;/etc/resolv.conf&#xD;
+    screen -dmS install-webserver /tmp/install-webserver &amp;&#xD;
+    exit 0&#xD;
+- path: /tmp/install-webserver&#xD;
+  owner: root:root&#xD;
+  permissions: '0755'&#xD;
+  content: |-&#xD;
+    #!/bin/bash&#xD;
+    echo "Waiting for internet connectivity"&#xD;
+    until echo -n "." &amp;&amp; ping -c1 archive.ubuntu.com &amp;&gt;/dev/null; do :; done&#xD;
+    apt-get -y update&#xD;
+    apt-get -y install apache2&#xD;
+    echo "&lt;h1&gt;Willkommen auf Server-B!&lt;/h1&gt;" &gt;/var/www/html/index.html&#xD;
+    read -p "Press any key..."&#xD;
     exit 0&#xD;
 </entry>
         </extensions>
-- 
GitLab