]> git.llucax.com Git - z.facultad/75.43/tp2.git/commitdiff
Se completan rutas y se agrega script.
authorLeandro Lucarella <llucax@gmail.com>
Mon, 4 Jul 2005 21:15:51 +0000 (21:15 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Mon, 4 Jul 2005 21:15:51 +0000 (21:15 +0000)
makeroute [new file with mode: 0755]
routers_labo.csv

diff --git a/makeroute b/makeroute
new file mode 100755 (executable)
index 0000000..09072bc
--- /dev/null
+++ b/makeroute
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+# vim: set et sw=4 sts=4 :
+
+def get_campos(line):
+    r = []
+    for c in line.split('\t'):
+        r.append(c.strip('"\n'))
+    return r
+
+def parse(f):
+    hosts = {}
+    line = f.readline()
+    while line:
+        if line.startswith('"tabla de ruteo de '):
+            host = line[19:-7]
+            hosts[host] = {}
+            line = f.readline()
+            hosts[host]['ifaces'] = []
+            while line and line.strip() <> '"red"\t"ip"\t"mascara"\t"gateway"\t"interfaz"\t"metrica"':
+                if line.startswith('"'):
+                    (iface, ip, mascara, broadcast) = get_campos(line)[:4]
+                    hosts[host]['ifaces'].append({
+                        'iface': iface,
+                        'ip': ip,
+                        'mascara': mascara,
+                        'broadcast': broadcast,
+                    })
+                line = f.readline()
+            line = f.readline()
+            hosts[host]['rutas'] = []
+            while line and line.strip() <> '"--"':
+                if line.startswith('"'):
+                    (red, ip, mascara, gateway, iface, metrica) = get_campos(line)
+                    if not metrica: metrica = "1"
+                    hosts[host]['rutas'].append({
+                        'red': red,
+                        'ip': ip,
+                        'mascara': mascara,
+                        'gateway': gateway,
+                        'iface': iface,
+                        'metrica': metrica,
+                        })
+                line = f.readline()
+        line = f.readline()
+    return hosts
+
+def main(host):
+    import sys, pprint
+    #pprint.pprint(parse(sys.stdin))
+    #sys.exit(1)
+    hosts = parse(sys.stdin)
+    for iface in hosts[host]['ifaces']:
+        if not iface['iface'].startswith('ppp'):
+            print 'ifconfig %(iface)s %(ip)s broadcast %(broadcast)s netmask %(mascara)s' % iface
+    for ruta in hosts[host]['rutas']:
+        if ruta['metrica'] <> "0":
+            print 'route add -net %(ip)s gw %(gateway)s netmask %(mascara)s dev %(iface)s metric %(metrica)s' % ruta
+
+if __name__ == '__main__':
+    import sys
+    main(sys.argv[1])
+
index fd47c9328ba352ce7db5774e95e3143fb786e1e0..c563534adc6a8864fe987799ccf6184c6a6ca350 100644 (file)
@@ -1,14 +1,13 @@
-"tabla de ruteo de h132 "                                      
-"eth0:0"       "192.168.1.3"                           
-"eth0:1"       "10.4.1.65"                             
-"eth0:2"       "10.6.11.193"                           
-"eth0:3"       "10.4.1.1"                              
-                                       
+"tabla de ruteo de h132"                                       
+"eth0:0"       "192.168.1.3"   "255.255.255.0" "192.168.1.255"         
+"eth0:1"       "10.4.1.65"     "255.255.255.192"       "10.4.1.127"            
+"eth0:2"       "10.6.11.193"   "255.255.255.240"       "10.6.11.207"           
+"eth0:3"       "10.4.1.1"      "255.255.255.224"       "10.4.1.0"              
 "red"  "ip"    "mascara"       "gateway"       "interfaz"      "metrica"
-"alf"  "192.168.1.0"   "255.255.255.0" "0.0.0.0"       "eth0:0"        
-"friends"      "10.4.1.64"     "255.255.255.192"       "0.0.0.0"       "eth0:1"        
-"csi"  "10.6.11.192"   "255.255.255.240"       "0.0.0.0"       "eth0:2"        
-"action"       "192.168.1.0"   "255.255.255.224"       "0.0.0.0"       "eth0:3"        
+"alf"  "192.168.1.0"   "255.255.255.0" "0.0.0.0"       "eth0:0"        0
+"friends"      "10.4.1.64"     "255.255.255.192"       "0.0.0.0"       "eth0:1"        0
+"csi"  "10.6.11.192"   "255.255.255.240"       "0.0.0.0"       "eth0:2"        0
+"action"       "10.4.1.0"      "255.255.255.224"       "0.0.0.0"       "eth0:3"        0
 "trfs" "10.22.1.192"   "255.255.255.224"       "10.4.1.2"      "eth0:3"        "2"
 "seinfeld"     "10.9.2.0"      "255.255.255.128"       "10.4.1.2"      "eth0:3"        "2"
 "heman"        "10.4.1.128"    "255.255.255.128"       "10.4.1.2"      "eth0:0"        "4"
 "swat" "10.4.1.36"     "255.255.255.252"       "10.4.1.2"      "eth0:0"        "3"
 "--"                                   
 "tabla de ruteo de h131"                                       
-"eth0:0"       "10.4.1.2"                              
-"ppp0" "10.4.1.34"                             
-                                       
+"eth0:0"       "10.4.1.2"      "255.255.255.224"       "10.4.1.31"             
+"ppp0" "10.4.1.34"     "255.255.255.252"       "10.4.1.35"             
 "red"  "ip"    "mascara"       "gateway"       "interfaz"      "metrica"
 "alf"  "192.168.1.0"   "255.255.255.0" "10.4.1.1"      "eth0:0"        "1"
 "friends"      "10.4.1.64"     "255.255.255.192"       "10.4.1.1"      "eth0:0"        "1"
 "csi"  "10.6.11.192"   "255.255.255.240"       "10.4.1.1"      "eth0:0"        "1"
-"action"       "192.168.1.0"   "255.255.255.224"       "0.0.0.0"       "eth0:0"        
+"action"       "10.4.1.0"      "255.255.255.224"       "0.0.0.0"       "eth0:0"        0
 "trfs" "10.22.1.192"   "255.255.255.224"       "10.4.1.33"     "ppp0"  "1"
 "seinfeld"     "10.9.2.0"      "255.255.255.128"       "10.4.1.33"     "ppp0"  "1"
 "heman"        "10.4.1.128"    "255.255.255.128"       "10.4.1.33"     "ppp0"  "3"
 "dukes"        "10.9.2.192"    "255.255.255.224"       "10.4.1.33"     "ppp0"  "3"
 "simpsons"     "10.4.2.0"      "255.255.255.0" "10.4.1.33"     "ppp0"  "4"
-"brigada"      "10.4.1.32"     "255.255.255.252"       "0.0.0.0"       "ppp0"  
+"brigada"      "10.4.1.32"     "255.255.255.252"       "0.0.0.0"       "ppp0"  0
 "swat" "10.4.1.36"     "255.255.255.252"       "10.4.1.33"     "ppp0"  "2"
 "--"                                   
 "tabla de ruteo de h118"                                       
-"eth0:0 "      "10.9.2.2"                              
-"eth0:1"       "10.22.1.194"                           
-"ppp0" "10.4.1.33"                             
+"eth0:0 "      "10.9.2.2"      "255.255.255.128"       "10.9.2.127"            
+"eth0:1"       "10.22.1.194"   "255.255.255.224"       "10.22.1.223"           
+"ppp0" "10.4.1.33"     "255.255.255.252"       "10.4.1.35"             
 "red"  "ip"    "mascara"       "gateway"       "interfaz"      "metrica"
 "alf"  "192.168.1.0"   "255.255.255.0" "10.4.1.34"     "ppp0"  "2"
 "friends"      "10.4.1.64"     "255.255.255.192"       "10.4.1.34"     "ppp0"  "2"
 "csi"  "10.6.11.192"   "255.255.255.240"       "10.4.1.34"     "ppp0"  "2"
-"action"       "192.168.1.0"   "255.255.255.224"       "10.4.1.34"     "ppp0"  "1"
-"trfs" "10.22.1.192"   "255.255.255.224"       "0.0.0.0"       "eth0:1"        
-"seinfeld"     "10.9.2.0"      "255.255.255.128"       "0.0.0.0"       "eth0:0"        
+"action"       "10.4.1.0"      "255.255.255.224"       "10.4.1.34"     "ppp0"  "1"
+"trfs" "10.22.1.192"   "255.255.255.224"       "0.0.0.0"       "eth0:1"        0
+"seinfeld"     "10.9.2.0"      "255.255.255.128"       "0.0.0.0"       "eth0:0"        0
 "heman"        "10.4.1.128"    "255.255.255.128"       "10.22.1.193"   "eth0:1"        "2"
 "dukes"        "10.9.2.192"    "255.255.255.224"       "10.22.1.193"   "eth0:1"        "2"
 "simpsons"     "10.4.2.0"      "255.255.255.0" "10.22.1.193"   "eth0:1"        "3"
-"brigada"      "10.4.1.32"     "255.255.255.252"       "0.0.0.0"       "ppp0"  
+"brigada"      "10.4.1.32"     "255.255.255.252"       "0.0.0.0"       "ppp0"  0
 "swat" "10.4.1.36"     "255.255.255.252"       "10.22.1.193"   "eth0:1"        "1"
 "--"                                   
 "tabla de ruteo de h116"                                       
-"eth0:0"       "10.22.1.193"                           
-"ppp0" "10.4.1.37"                             
+"eth0:0"       "10.22.1.193"   "255.255.255.224"       "10.22.1.223"           
+"ppp0" "10.4.1.37"     "255.255.255.252"       "10.4.1.39"             
 "red"  "ip"    "mascara"       "gateway"       "interfaz"      "metrica"
 "alf"  "192.168.1.0"   "255.255.255.0" "10.22.1.194"   "eth0:0"        "3"
 "friends"      "10.4.1.64"     "255.255.255.192"       "10.22.1.194"   "eth0:0"        "3"
 "csi"  "10.6.11.192"   "255.255.255.240"       "10.22.1.194"   "eth0:0"        "3"
-"action"       "192.168.1.0"   "255.255.255.224"       "10.22.1.194"   "eth0:0"        "2"
-"trfs" "10.22.1.192"   "255.255.255.224"       "0.0.0.0"       "eth0:0"        
+"action"       "10.4.1.0"      "255.255.255.224"       "10.22.1.194"   "eth0:0"        "2"
+"trfs" "10.22.1.192"   "255.255.255.224"       "0.0.0.0"       "eth0:0"        0
 "seinfeld"     "10.9.2.0"      "255.255.255.128"       "10.22.1.194"   "eth0:0"        "1"
 "heman"        "10.4.1.128"    "255.255.255.128"       "10.4.1.38"     "ppp0"  "1"
 "dukes"        "10.9.2.192"    "255.255.255.224"       "10.4.1.38"     "ppp0"  "1"
 "simpsons"     "10.4.2.0"      "255.255.255.0" "10.4.1.38"     "ppp0"  "2"
 "brigada"      "10.4.1.32"     "255.255.255.252"       "10.22.1.194"   "eth0:0"        "1"
-"swat" "10.4.1.36"     "255.255.255.252"       "0.0.0.0"       "ppp0"  "3"
+"swat" "10.4.1.36"     "255.255.255.252"       "0.0.0.0"       "ppp0"  "0"
 "--"                                   
 "tabla de ruteo de h108"                                       
-"eth0:0"       "10.4.1.130"                            
-"eth0:1"       "10.9.2.196"                            
-"ppp0" "10.4.1.38"                             
+"eth0:0"       "10.4.1.130"    "255.255.255.252"       "10.4.1.39"             
+"eth0:1"       "10.9.2.196"    "255.255.255.224"       "10.9.2.223"            
+"ppp0" "10.4.1.38"     "255.255.255.128"       "10.4.1.255"            
 "red"  "ip"    "mascara"       "gateway"       "interfaz"      "metrica"
 "alf"  "192.168.1.0"   "255.255.255.0" "10.4.1.37"     "ppp0"  "4"
 "friends"      "10.4.1.64"     "255.255.255.192"       "10.4.1.37"     "ppp0"  "4"
 "csi"  "10.6.11.192"   "255.255.255.240"       "10.4.1.37"     "ppp0"  "4"
-"action"       "192.168.1.0"   "255.255.255.224"       "10.4.1.37"     "ppp0"  "3"
+"action"       "10.4.1.0"      "255.255.255.224"       "10.4.1.37"     "ppp0"  "3"
 "trfs" "10.22.1.192"   "255.255.255.224"       "10.4.1.37"     "ppp0"  "1"
 "seinfeld"     "10.9.2.0"      "255.255.255.128"       "10.4.1.37"     "ppp0"  "2"
-"heman"        "10.4.1.128"    "255.255.255.128"       "0.0.0.0"       "eth0:0"        
-"dukes"        "10.9.2.192"    "255.255.255.224"       "0.0.0.0"       "eth0:1"        
+"heman"        "10.4.1.128"    "255.255.255.128"       "0.0.0.0"       "eth0:0"        0
+"dukes"        "10.9.2.192"    "255.255.255.224"       "0.0.0.0"       "eth0:1"        0
 "simpsons"     "10.4.2.0"      "255.255.255.0" "10.9.2.194"    "eth0:1"        "1"
 "simpsons"     "10.4.2.0"      "255.255.255.0" "10.9.2.193"    "eth0:1"        "1"
 "brigada"      "10.4.1.32"     "255.255.255.252"       "10.4.1.37"     "ppp0"  "2"
-"swat" "10.4.1.36"     "255.255.255.252"       "0.0.0.0"       "ppp0"  
+"swat" "10.4.1.36"     "255.255.255.252"       "0.0.0.0"       "ppp0"  0
 "--"                                   
 "tabla de ruteo de h106"                                       
-"eth0:0"       "10.9.2.194"                            
-"eth0:1"       "10.4.2.2"                              
+"eth0:0"       "10.9.2.194"    "255.255.255.224"       "10.9.2.223"            
+"eth0:1"       "10.4.2.2"      "255.255.255.0" "10.4.2.255"            
 "red"  "ip"    "mascara"       "gateway"       "interfaz"      "metrica"
 "alf"  "192.168.1.0"   "255.255.255.0" "10.9.2.196"    "eth0:0"        "5"
 "alf"  "192.168.1.0"   "255.255.255.0" "10.4.2.1"      "eth0:1"        "6"
 "friends"      "10.4.1.64"     "255.255.255.192"       "10.4.2.1"      "eth0:1"        "6"
 "csi"  "10.6.11.192"   "255.255.255.240"       "10.9.2.196"    "eth0:0"        "5"
 "csi"  "10.6.11.192"   "255.255.255.240"       "10.4.2.1"      "eth0:1"        "6"
-"action"       "192.168.1.0"   "255.255.255.224"       "10.9.2.196"    "eth0:0"        "4"
-"action"       "192.168.1.0"   "255.255.255.224"       "10.4.2.1"      "eth0:1"        "5"
+"action"       "10.4.1.0"      "255.255.255.224"       "10.9.2.196"    "eth0:0"        "4"
+"action"       "10.4.1.0"      "255.255.255.224"       "10.4.2.1"      "eth0:1"        "5"
 "trfs" "10.22.1.192"   "255.255.255.224"       "10.9.2.196"    "eth0:0"        "2"
 "trfs" "10.22.1.192"   "255.255.255.224"       "10.4.2.1"      "eth0:1"        "3"
 "seinfeld"     "10.9.2.0"      "255.255.255.128"       "10.9.2.196"    "eth0:0"        "3"
 "seinfeld"     "10.9.2.0"      "255.255.255.128"       "10.4.2.1"      "eth0:1"        "4"
 "heman"        "10.4.1.128"    "255.255.255.128"       "10.9.2.196"    "eth0:0"        "1"
 "heman"        "10.4.1.128"    "255.255.255.128"       "10.4.2.1"      "eth0:1"        "2"
-"dukes"        "10.9.2.192"    "255.255.255.224"       "0.0.0.0"       "eth0:0"        
-"simpsons"     "10.4.2.0"      "255.255.255.0" "0.0.0.0"       "eth0:1"        
+"dukes"        "10.9.2.192"    "255.255.255.224"       "0.0.0.0"       "eth0:0"        0
+"simpsons"     "10.4.2.0"      "255.255.255.0" "0.0.0.0"       "eth0:1"        0
 "brigada"      "10.4.1.32"     "255.255.255.252"       "10.9.2.196"    "eth0:0"        "3"
 "brigada"      "10.4.1.32"     "255.255.255.252"       "10.4.2.1"      "eth0:1"        "4"
 "swat" "10.4.1.36"     "255.255.255.252"       "10.9.2.196"    "eth0:0"        "1"
 "swat" "10.4.1.36"     "255.255.255.252"       "10.4.2.1"      "eth0:1"        "2"
 "--"                                   
 "tabla de ruteo de h103"                                       
-"eth0:0"       "10.9.2.193"                            
-"eth0:1"       "10.4.2.1"                              
+"eth0:0"       "10.9.2.193"    "255.255.255.224"       "10.9.2.223"            
+"eth0:1"       "10.4.2.1"      "255.255.255.0" "10.4.2.255"            
 "red"  "ip"    "mascara"       "gateway"       "interfaz"      "metrica"
 "alf"  "192.168.1.0"   "255.255.255.0" "10.9.2.196"    "eth0:0"        "5"
 "alf"  "192.168.1.0"   "255.255.255.0" "10.4.2.2"      "eth0:1"        "6"
 "friends"      "10.4.1.64"     "255.255.255.192"       "10.4.2.2"      "eth0:1"        "6"
 "csi"  "10.6.11.192"   "255.255.255.240"       "10.9.2.196"    "eth0:0"        "5"
 "csi"  "10.6.11.192"   "255.255.255.240"       "10.4.2.2"      "eth0:1"        "6"
-"action"       "192.168.1.0"   "255.255.255.224"       "10.9.2.196"    "eth0:0"        "4"
-"action"       "192.168.1.0"   "255.255.255.224"       "10.4.2.2"      "eth0:1"        "5"
+"action"       "10.4.1.0"      "255.255.255.224"       "10.9.2.196"    "eth0:0"        "4"
+"action"       "10.4.1.0"      "255.255.255.224"       "10.4.2.2"      "eth0:1"        "5"
 "trfs" "10.22.1.192"   "255.255.255.224"       "10.9.2.196"    "eth0:0"        "2"
 "trfs" "10.22.1.192"   "255.255.255.224"       "10.4.2.2"      "eth0:1"        "3"
 "seinfeld"     "10.9.2.0"      "255.255.255.128"       "10.9.2.196"    "eth0:0"        "3"
 "seinfeld"     "10.9.2.0"      "255.255.255.128"       "10.4.2.2"      "eth0:1"        "4"
 "heman"        "10.4.1.128"    "255.255.255.128"       "10.9.2.196"    "eth0:0"        "1"
 "heman"        "10.4.1.128"    "255.255.255.128"       "10.4.2.2"      "eth0:1"        "2"
-"dukes"        "10.9.2.192"    "255.255.255.224"       "0.0.0.0"       "eth0:0"        
-"simpsons"     "10.4.2.0"      "255.255.255.0" "0.0.0.0"       "eth0:1"        
+"dukes"        "10.9.2.192"    "255.255.255.224"       "0.0.0.0"       "eth0:0"        0
+"simpsons"     "10.4.2.0"      "255.255.255.0" "0.0.0.0"       "eth0:1"        0
 "brigada"      "10.4.1.32"     "255.255.255.252"       "10.9.2.196"    "eth0:0"        "3"
 "brigada"      "10.4.1.32"     "255.255.255.252"       "10.4.2.2"      "eth0:1"        "4"
 "swat" "10.4.1.36"     "255.255.255.252"       "10.9.2.196"    "eth0:0"        "1"