facebook link >> https://www.facebook.com/silentDimension5D/posts/492125414244985
Python for Networker Intro 2
ZawGyi
CentOS သြင္းရတာ ေလးတယ္ဆိုတဲ့ ညီအကိုေတြ အတြက္... gns3.com ကေန ေပးထားတဲ့ ubuntu appliance ေလးရွိတယ္ဗ်ာ့..
https://gns3.com/marketplace/appliance/ubuntu
အဲ့လင့္ေန down လိုက္ရင္ ubuntu.gns3a ဆုိတဲ့ file ေလးရလိမ့္မယ္..
GNS3 Menu Bar ကေနျပီးေတာ့ import appliance >> ျပီးေတာ့ down ထားတဲ့ file location ေရြးေပးလိုက္ပါ click open
Next >> Run the applicance on the GNS3 VM ကိုေရြးေပးပါ >> Next >> click finish
https://gns3.com/marketplace/appliance/ubuntu
အဲ့လင့္ေန down လိုက္ရင္ ubuntu.gns3a ဆုိတဲ့ file ေလးရလိမ့္မယ္..
GNS3 Menu Bar ကေနျပီးေတာ့ import appliance >> ျပီးေတာ့ down ထားတဲ့ file location ေရြးေပးလိုက္ပါ click open
Next >> Run the applicance on the GNS3 VM ကိုေရြးေပးပါ >> Next >> click finish
ျပီးေတာ့ တုိ့ေတြသြင္းထားတဲ့ ubuntu က end device listထဲကို ေရာက္ေနလိမ့္မယ္ ဖိဆြဲျပီးတင္လိုက္ပါ.. သူ့ဘာသာ install လုပ္သြားပါလိမ့္မယ္
internet connection ေတာ့လိုတယ္ဗ်ာ့ ပံု1 ပံု2 ပံု၃
internet connection ေတာ့လိုတယ္ဗ်ာ့ ပံု1 ပံု2 ပံု၃



Topology ပံု topo
Ubuntu PC ကို right click ေထာက္ျပီး Edit config ကိုသြားပါ ပံု 4
Nat Cloud က DHCP support ေပးတဲ့ အတြက္ Ubuntu ရဲ့ eth0 ကို dhcp on ေပးလိုက္ပါ ပံု5

Nat Cloud က DHCP support ေပးတဲ့ အတြက္ Ubuntu ရဲ့ eth0 ကို dhcp on ေပးလိုက္ပါ ပံု5

Nat Cloud က GNS3 2.0 မွာ support ေပးပါတယ္...
GNS3 1.5 အတြက္ဆုိ https://websistent.com/how-to-connect-gns3-to-the-internet/
အဲ့လင့္မွာ ပါတဲ့အတုိင္း config ခ် ပါ
GNS3 1.5 အတြက္ဆုိ https://websistent.com/how-to-connect-gns3-to-the-internet/
အဲ့လင့္မွာ ပါတဲ့အတုိင္း config ခ် ပါ
second 20 ေလာက္ ေနရင္ ip က်လာပါလိမ့္မယ္ .. မရခဲ့ရင္
$ifconfig eth0 down
$ifconfig eth0 up
eth0 interface ကို disable/enable လုပ္ေပးပါ
Now got IP ပံု 6
internet connection ရ မရ ping ျကည့္ပါ... ျပီးေတာ့ $apt-get update လုပ္ပါ ပံု7
လုပ္ျပီးရင္ python install လုပ္ပါ ပံု8
python အလုပ္ လုပ္ မလုပ္ စမ္းျကည့္ပါ ....
root@Ubuntu-11:~#python
>>>print("Helloworld")
Helloworld
>>>
ပံု9
$ifconfig eth0 down
$ifconfig eth0 up
eth0 interface ကို disable/enable လုပ္ေပးပါ
Now got IP ပံု 6

internet connection ရ မရ ping ျကည့္ပါ... ျပီးေတာ့ $apt-get update လုပ္ပါ ပံု7

လုပ္ျပီးရင္ python install လုပ္ပါ ပံု8

python အလုပ္ လုပ္ မလုပ္ စမ္းျကည့္ပါ ....
root@Ubuntu-11:~#python
>>>print("Helloworld")
Helloworld
>>>
ပံု9

window အတြက္တင္မဟုတ္ပါဘူး linux မွာလဲ အလုပ္လုပ္ပါတယ္... ပံု 9.1

တုိ့ေတြ Vlan configuration လုပ္မယ့္ switch ေတြကိုလဲ Ubuntu ရဲ့ IP နဲ ့ Same Network ျဖစ္ေအာင္ ေပးပါ
$ifconfig eth0 ဆိုျပီး ျကည့္လုိက္ရင္ ip:192.168.122.33 & Mask:255.255.255.0
အဲ့ေတာ့ switch1,switch2,switch3 ကို vlan 1 interface ကို 192.168.122.11, 192.168.122.12, 192.168.122.13 ဆုိျပီး ေပးလိုက္တယ္ဗ်ာ့ ပံု10
$ifconfig eth0 ဆိုျပီး ျကည့္လုိက္ရင္ ip:192.168.122.33 & Mask:255.255.255.0
အဲ့ေတာ့ switch1,switch2,switch3 ကို vlan 1 interface ကို 192.168.122.11, 192.168.122.12, 192.168.122.13 ဆုိျပီး ေပးလိုက္တယ္ဗ်ာ့ ပံု10

https://drive.google.com/file/d/0B6-W5TOkUugea2JSc0JhTG5UR1k/view
အဲ့လင့္က script အတိုင္း ရိုက္ပါ.. python မွာ space ေတြ tab ေတြ သတိထားပါ.. for loop ပါတ္တဲ့အခ်ိန္မွာ..
;-)
ပံု 11
########################## Script ###########################
import getpass
import sys
import telnetlib
အဲ့လင့္က script အတိုင္း ရိုက္ပါ.. python မွာ space ေတြ tab ေတြ သတိထားပါ.. for loop ပါတ္တဲ့အခ်ိန္မွာ..

ပံု 11

########################## Script ###########################
import getpass
import sys
import telnetlib
vlan_count=1
no_device=raw_input("How many device do you want to configure: ")
device=int(no_device) /// ၀င္လာတာက str typeပါ အဲ့ေျကာင့္ int type ေျပာင္းတာပါ..for loopမွာ integer ထည့္ရမွာမုိ့
no_vlan=raw_input("How manay Vlan do you want to config: ")
vlan=int(no_vlan) /// ၀င္လာတာက str typeပါ အဲ့ေျကာင့္ int type ေျပာင္းတာပါ..for loopမွာ integer ထည့္ရမွာမုိ့
device=int(no_device) /// ၀င္လာတာက str typeပါ အဲ့ေျကာင့္ int type ေျပာင္းတာပါ..for loopမွာ integer ထည့္ရမွာမုိ့
no_vlan=raw_input("How manay Vlan do you want to config: ")
vlan=int(no_vlan) /// ၀င္လာတာက str typeပါ အဲ့ေျကာင့္ int type ေျပာင္းတာပါ..for loopမွာ integer ထည့္ရမွာမုိ့
for i in range(device): /// for loop ပါတ္ပါတယ္ i=0ကေနစျပီး 1 တုိုး တုိးသြားျပီး <device ထိပါ
HOST=raw_input("Enter Your Devie IP: ")
user=raw_input("Enter Your Telnet UserName: ")
password=getpass.getpass()
tln=telnetlib.Telnet(HOST)
tln.read_until("Username: ")
tln.write(user + "\n")
if password:
tln.read_until("Password: ")
tln.write(password + "\n")
tln.write("enable\n")
tln.write("cisco\n")
tln.write("conf t\n")
for i in range(vlan): /// for loop ပါတ္ပါတယ္ i=0ကေနစျပီး 1 တုိုး တုိးသြားျပီး <device ထိပါ
vlan_count=vlan_count+1
tln.write("vlan " + str(vlan_count) + "\n")
tln.write("name VLAN" + str(vlan_count) + "\n")
tln.write("exit\n")
tln.write("end\n")
tln.write("exit\n")
print tln.read_all()
HOST=raw_input("Enter Your Devie IP: ")
user=raw_input("Enter Your Telnet UserName: ")
password=getpass.getpass()
tln=telnetlib.Telnet(HOST)
tln.read_until("Username: ")
tln.write(user + "\n")
if password:
tln.read_until("Password: ")
tln.write(password + "\n")
tln.write("enable\n")
tln.write("cisco\n")
tln.write("conf t\n")
for i in range(vlan): /// for loop ပါတ္ပါတယ္ i=0ကေနစျပီး 1 တုိုး တုိးသြားျပီး <device ထိပါ
vlan_count=vlan_count+1
tln.write("vlan " + str(vlan_count) + "\n")
tln.write("name VLAN" + str(vlan_count) + "\n")
tln.write("exit\n")
tln.write("end\n")
tln.write("exit\n")
print tln.read_all()
sublime text နဲ့ ေရးျကည့္ပါ ကိုယ့္ loop ဘယ္နားထိေရာက္လဲ ျမင္သာပါတယ္....
;-)
for loop ဘယ္လုိ အလုပ္လုပ္လဲ ဆုိ တာကို ေနာက္ဆံုးပံုမွာ ျကည့္ပါ

for loop ဘယ္လုိ အလုပ္လုပ္လဲ ဆုိ တာကို ေနာက္ဆံုးပံုမွာ ျကည့္ပါ
vlan creation finished with python script ပံု 12

Thanks for your reading
~[F]or-get
~[F]or-get
Uni Code
CentOS သွင်းရတာ လေးတယ်ဆိုတဲ့ ညီအကိုတွေ အတွက်... gns3.com ကနေ ပေးထားတဲ့ ubuntu appliance လေးရှိတယ်ဗျာ့..
https://gns3.com/marketplace/appliance/ubuntu
အဲ့လင့်နေ down လိုက်ရင် ubuntu.gns3a ဆိုတဲ့ file လေးရလိမ့်မယ်..
GNS3 Menu Bar ကနေပြီးတော့ import appliance >> ပြီးတော့ down ထားတဲ့ file location ရွေးပေးလိုက်ပါ click open
Next >> Run the applicance on the GNS3 VM ကိုရွေးပေးပါ >> Next >> click finish
https://gns3.com/marketplace/appliance/ubuntu
အဲ့လင့်နေ down လိုက်ရင် ubuntu.gns3a ဆိုတဲ့ file လေးရလိမ့်မယ်..
GNS3 Menu Bar ကနေပြီးတော့ import appliance >> ပြီးတော့ down ထားတဲ့ file location ရွေးပေးလိုက်ပါ click open
Next >> Run the applicance on the GNS3 VM ကိုရွေးပေးပါ >> Next >> click finish
ပြီးတော့ တို့တွေသွင်းထားတဲ့ ubuntu က end device listထဲကို ရောက်နေလိမ့်မယ် ဖိဆွဲပြီးတင်လိုက်ပါ.. သူ့ဘာသာ install လုပ်သွားပါလိမ့်မယ်
internet connection တော့လိုတယ်ဗျာ့ ပုံ1 ပုံ2 ပုံ၃
internet connection တော့လိုတယ်ဗျာ့ ပုံ1 ပုံ2 ပုံ၃
Topology ပုံ topo
Ubuntu PC ကို right click ထောက်ပြီး Edit config ကိုသွားပါ ပုံ 4
Nat Cloud က DHCP support ပေးတဲ့ အတွက် Ubuntu ရဲ့ eth0 ကို dhcp on ပေးလိုက်ပါ ပုံ5
Nat Cloud က DHCP support ပေးတဲ့ အတွက် Ubuntu ရဲ့ eth0 ကို dhcp on ပေးလိုက်ပါ ပုံ5
Nat Cloud က GNS3 2.0 မှာ support ပေးပါတယ်...
GNS3 1.5 အတွက်ဆို https://websistent.com/how-to-connect-gns3-to-the-internet/
အဲ့လင့်မှာ ပါတဲ့အတိုင်း config ချ ပါ
GNS3 1.5 အတွက်ဆို https://websistent.com/how-to-connect-gns3-to-the-internet/
အဲ့လင့်မှာ ပါတဲ့အတိုင်း config ချ ပါ
second 20 လောက် နေရင် ip ကျလာပါလိမ့်မယ် .. မရခဲ့ရင်
$ifconfig eth0 down
$ifconfig eth0 up
eth0 interface ကို disable/enable လုပ်ပေးပါ
Now got IP ပုံ 6
internet connection ရ မရ ping ကြည့်ပါ... ပြီးတော့ $apt-get update လုပ်ပါ ပုံ7
လုပ်ပြီးရင် python install လုပ်ပါ ပုံ8
python အလုပ် လုပ် မလုပ် စမ်းကြည့်ပါ ....
root@Ubuntu-11:~#python
>>>print("Helloworld")
Helloworld
>>>
ပုံ9
$ifconfig eth0 down
$ifconfig eth0 up
eth0 interface ကို disable/enable လုပ်ပေးပါ
Now got IP ပုံ 6
internet connection ရ မရ ping ကြည့်ပါ... ပြီးတော့ $apt-get update လုပ်ပါ ပုံ7
လုပ်ပြီးရင် python install လုပ်ပါ ပုံ8
python အလုပ် လုပ် မလုပ် စမ်းကြည့်ပါ ....
root@Ubuntu-11:~#python
>>>print("Helloworld")
Helloworld
>>>
ပုံ9
window အတွက်တင်မဟုတ်ပါဘူး linux မှာလဲ အလုပ်လုပ်ပါတယ်... ပုံ 9.1
တို့တွေ Vlan configuration လုပ်မယ့် switch တွေကိုလဲ Ubuntu ရဲ့ IP နဲ ့ Same Network ဖြစ်အောင် ပေးပါ
$ifconfig eth0 ဆိုပြီး ကြည့်လိုက်ရင် ip:192.168.122.33 & Mask:255.255.255.0
အဲ့တော့ switch1,switch2,switch3 ကို vlan 1 interface ကို 192.168.122.11, 192.168.122.12, 192.168.122.13 ဆိုပြီး ပေးလိုက်တယ်ဗျာ့ ပုံ10
$ifconfig eth0 ဆိုပြီး ကြည့်လိုက်ရင် ip:192.168.122.33 & Mask:255.255.255.0
အဲ့တော့ switch1,switch2,switch3 ကို vlan 1 interface ကို 192.168.122.11, 192.168.122.12, 192.168.122.13 ဆိုပြီး ပေးလိုက်တယ်ဗျာ့ ပုံ10
https://drive.google.com/…/0B6-W5TOkUugea2JSc0JhTG5UR…/view…
အဲ့လင့်က script အတိုင်း ရိုက်ပါ.. python မှာ space တွေ tab တွေ သတိထားပါ.. for loop ပါတ်တဲ့အချိန်မှာ..
;-)
ပုံ 11
########################## Script ###########################
import getpass
import sys
import telnetlib
အဲ့လင့်က script အတိုင်း ရိုက်ပါ.. python မှာ space တွေ tab တွေ သတိထားပါ.. for loop ပါတ်တဲ့အချိန်မှာ..

ပုံ 11
########################## Script ###########################
import getpass
import sys
import telnetlib
vlan_count=1
no_device=raw_input("How many device do you want to configure: ")
device=int(no_device) /// ၀င်လာတာက str typeပါ အဲ့ကြောင့် int type ပြောင်းတာပါ..for loopမှာ integer ထည့်ရမှာမို့
no_vlan=raw_input("How manay Vlan do you want to config: ")
vlan=int(no_vlan) /// ၀င်လာတာက str typeပါ အဲ့ကြောင့် int type ပြောင်းတာပါ..for loopမှာ integer ထည့်ရမှာမို့
device=int(no_device) /// ၀င်လာတာက str typeပါ အဲ့ကြောင့် int type ပြောင်းတာပါ..for loopမှာ integer ထည့်ရမှာမို့
no_vlan=raw_input("How manay Vlan do you want to config: ")
vlan=int(no_vlan) /// ၀င်လာတာက str typeပါ အဲ့ကြောင့် int type ပြောင်းတာပါ..for loopမှာ integer ထည့်ရမှာမို့
for i in range(device): /// for loop ပါတ်ပါတယ် i=0ကနေစပြီး 1 တိုုး တိုးသွားပြီး <device ထိပါ
HOST=raw_input("Enter Your Devie IP: ")
user=raw_input("Enter Your Telnet UserName: ")
password=getpass.getpass()
tln=telnetlib.Telnet(HOST)
tln.read_until("Username: ")
tln.write(user + "\n")
if password:
tln.read_until("Password: ")
tln.write(password + "\n")
tln.write("enable\n")
tln.write("cisco\n")
tln.write("conf t\n")
for i in range(vlan): /// for loop ပါတ်ပါတယ် i=0ကနေစပြီး 1 တိုုး တိုးသွားပြီး <device ထိပါ
vlan_count=vlan_count+1
tln.write("vlan " + str(vlan_count) + "\n")
tln.write("name VLAN" + str(vlan_count) + "\n")
tln.write("exit\n")
tln.write("end\n")
tln.write("exit\n")
print tln.read_all()
HOST=raw_input("Enter Your Devie IP: ")
user=raw_input("Enter Your Telnet UserName: ")
password=getpass.getpass()
tln=telnetlib.Telnet(HOST)
tln.read_until("Username: ")
tln.write(user + "\n")
if password:
tln.read_until("Password: ")
tln.write(password + "\n")
tln.write("enable\n")
tln.write("cisco\n")
tln.write("conf t\n")
for i in range(vlan): /// for loop ပါတ်ပါတယ် i=0ကနေစပြီး 1 တိုုး တိုးသွားပြီး <device ထိပါ
vlan_count=vlan_count+1
tln.write("vlan " + str(vlan_count) + "\n")
tln.write("name VLAN" + str(vlan_count) + "\n")
tln.write("exit\n")
tln.write("end\n")
tln.write("exit\n")
print tln.read_all()
sublime text နဲ့ ရေးကြည့်ပါ ကိုယ့် loop ဘယ်နားထိရောက်လဲ မြင်သာပါတယ်....
;-)
for loop ဘယ်လို အလုပ်လုပ်လဲ ဆို တာကို နောက်ဆုံးပုံမှာ ကြည့်ပါ

for loop ဘယ်လို အလုပ်လုပ်လဲ ဆို တာကို နောက်ဆုံးပုံမှာ ကြည့်ပါ
vlan creation finished with python script ပုံ 12
Thanks for your reading
~[F]or-get
~[F]or-get
Comments
Post a Comment