tujuan lab adalah memberi IP DHCP kepada client pada router cisco. sebelum dimulai yang dibutuhkan adalah :
- cisco router
- python2.7
- komputer controller (untuk telnet router cisco)
langkah kerja :
1. pastikan komputer controller terhubung dengan routernya
2. buat program pythonnya seperti berikut:(python1.py)
#Bismillah
import getpass
import sys
import telnetlib
HOST = "10.10.10.2"
user = raw_input("Enter your telnet username: ")
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
tn.read_until("Username")
tn.write(user + "\n")
if password:
tn.read_until ("Password:")
tn.write(password + "\n")
#memberi IP di interface GigabitEthernet2/0
tn.write("enable\n")
tn.write("huda\n")
tn.write("conf t\n")
tn.write("int GigabitEthernet2/0\n")
tn.write("ip address 20.20.20.1 255.255.255.0\n")
#memberi IP DHCP
tn.write("no sh\n")
tn.write("ip dhcp pool vlan1\n")
tn.write("network 20.20.20.0 255.255.255.0\n")
tn.write("default-router 20.20.20.1\n")
tn.write("dns-server 20.20.20.1\n")
tn.write("end\n")
tn.write("exit\n")
print tn.read_all()
3. jalankan program pythonnya
python2 python2.py
0 komentar:
Posting Komentar