Friday, 7 April 2017

Installing and configure DHCP server



Installing and configure DHCP server and


write a program (C++\Python\Java)


to install the software on remote machine.






#!/usr/bin/python

import os
import commands
while True:
x=int(raw_input("1.Install and configure DHCP\n2.Install an software on remote machine\n"))

if x==1:
current_ip=commands.getoutput("hostname -I")
print "Current IP address is : " , current_ip
os.system("yum remove dhcp")
os.system("yum install dhcp")
os.system("vi /etc/dhcp/dhcpd.conf")
os.system("systemctl start dhcpd.service")
os.system("systemctl enable dhcpd.service")
os.system("chkconfig dhcpd on")
os.system("service dhcpd restart")
current_ip=commands.getoutput("hostname -I")
print "Current IP address is : " , current_ip

if x==2:
os.system("ssh TE@192.168.5.77") 

OUTPUT:

[root@localhost]# python a4.py
1.Install and configure DHCP
2.Install an software on remote machine
1
Current IP address is : 192.168.5.76
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.7-2.fc20 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===================================
Package Arch Version Repository Size
===================================
Removing:
dhcp x86_64 12:4.2.7-2.fc20 @updates 1.4 M

Transaction Summary
===================================
Remove 1 Package

Installed size: 1.4 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : 12:dhcp-4.2.7-2.fc20.x86_64 1/1
warning: /etc/dhcp/dhcpd.conf saved as /etc/dhcp/dhcpd.conf.rpmsave
Verifying : 12:dhcp-4.2.7-2.fc20.x86_64 1/1

Removed:
dhcp.x86_64 12:4.2.7-2.fc20

Complete!
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package dhcp.x86_64 12:4.2.7-2.fc20 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================
Package Arch Version Repository Size
===================================
Installing:
dhcp x86_64 12:4.2.7-2.fc20 updates 516 k

Transaction Summary
===================================
Install 1 Package

Total download size: 516 k
Installed size: 1.4 M
Is this ok [y/d/N]: y
Downloading packages:
dhcp-4.2.7-2.fc20.x86_64.rpm | 516 kB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 12:dhcp-4.2.7-2.fc20.x86_64 1/1
Verifying : 12:dhcp-4.2.7-2.fc20.x86_64 1/1

Installed:
dhcp.x86_64 12:4.2.7-2.fc20

Complete!
ln -s '/usr/lib/systemd/system/dhcpd.service' '/etc/systemd/system/multi-user.target.wants/dhcpd.service'
Note: Forwarding request to 'systemctl enable dhcpd.service'.
Redirecting to /bin/systemctl restart dhcpd.service
Current IP address is : 192.168.5.76
1.Install and configure DHCP
2.Install an software on remote machine
2
TE3@192.168.5.77's password:
Last login: Tue Feb 7 14:14:14 2017 from 192.168.5.76
[TE3@localhost ~]$ su
Password:
[root@localhost]# yum remove wireshark
Loaded plugins: langpacks, refresh-packagekit
No Match for argument: wireshark
No Packages marked for removal
[root@localhost]# yum install wireshark
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package wireshark.x86_64 0:1.10.14-1.fc20 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================
Package Arch Version Repository Size
===================================
Installing:
wireshark x86_64 1.10.14-1.fc20 updates 13 M

Transaction Summary
===================================
Install 1 Package

Total download size: 13 M
Installed size: 69 M
Is this ok [y/d/N]: y
Downloading packages:
wireshark-1.10.14-1.fc20.x86_64.rpm | 13 MB 00:00:24
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wireshark-1.10.14-1.fc20.x86_64 1/1
Verifying : wireshark-1.10.14-1.fc20.x86_64 1/1

Installed:
wireshark.x86_64 0:1.10.14-1.fc20

Complete!
[root@localhost]# whereis wireshark
wireshark: /usr/lib64/wireshark /usr/share/wireshark
[root@localhost]# yum remove wireshark
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package wireshark.x86_64 0:1.10.14-1.fc20 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

===================================
Package Arch Version Repository Size
===================================
Removing:
wireshark x86_64 1.10.14-1.fc20 @updates 69 M

Transaction Summary
===================================
Remove 1 Package

Installed size: 69 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : wireshark-1.10.14-1.fc20.x86_64 1/1
Verifying : wireshark-1.10.14-1.fc20.x86_64 1/1

Removed:
wireshark.x86_64 0:1.10.14-1.fc20

Complete!
[root@localhost]# whereis wireshark
wireshark:[root@localhost]# exit
exit
[TE3@localhost ~]$ exit
logout
Connection to 192.168.5.77 closed.
1.Install and configure DHCP
2.Install an software on remote machine
^Z
[1]+ Stopped python a4.py
[root@localhost]# exit
exit







No comments:

Post a Comment