LAB DHCP - Execute the following procedure on the VM :

ifconfig eth0 20.0.13.14

dhcp 1. SCENARIO 1 scp [email protected]:dhcp/* dhcp

Remember that if you are using the remote espec, the login is the same as you used to connect via SSH or VNC. If you are using the VMware image, the login and password are rss and pucpos, respectively .

3. DHCP SERVER CONFIGURATION

In this first scenario, you must create three virtual machines, as shown in Fig. The G1 VM acts as a router and a DHCP server (which is a common practice in many systems).

2. VMS IN SCENARIO 1

The figure illustrates the IP addresses assignment for Download the package with the required files in your home scenario 1. The 13.14.0.0/24 and 13.14.1.0/24 subnets directory: assumes your student code is ( 101 ) 11.12.13.14 - x . You must replace the prefix 13:14 to match your actual student wget espec.ppgia.pucpr.br/jam_pacotes/dhcp.tar.gz code. tar -xzf dhcp.tar.gz The following procedure should be performed on the VM Take care to not cause conflicts with the addresses of other G1. A dhcpd.conf in the dhcp directory is created when VMs running on the espec server. For this, assuming your you unzip dhcp.tar.gz package. Edit this file using , student code is (101) 11 12 13 14 -x , choose the following changing addresses in accordance with your student code. addresses: After making these changes, copy the dhcpd.conf file to the G : 20.0.13.14 /etc directory: H1: 20.1.13.14 H2 : 20.2.13.14 /root/dhcp dhcpd.conf /etc/dhcp First, open a terminal in the espec, and create a directory to store the virtual machines: Create VLANs and assign IP addresses to the router interfaces. mkdir dhcplab cd dhcplab vconfig add eth0 2 ifconfig eth0.2 13.14.0.1/24 Create the first virtual machine to represent the gateway vconfig add eth0 3 G1: ifconfig eth0.3 13.14.1.1/24 sysctl -w net.ipv4.ip_forward=1 linux32.redes G1 login: root Run the dhcpd server with the following command: dhcpd

If you receive an error message, you must correct the /etc/dhcpd.conf and restart the dhcpd server. You need to restart the dchpd server if you any changes in the dhcpd.conf file. service dhcpd restart

The message about eth0 is not an error and can be ignored (it simply reports that there is no subnet for interface eth0).

4. CONFIGURATION You don´t need a dhclient installed on a host to use DHCP. Each host interface can be configured automatically when booting the using a startup script ifcfg- ethX in /etc/sysconfig/network-scripts directory.

To H2 host, we will use this strategy. If you have not done so, create a virtual machine to represent the host H2:

linux32.redes H2

Execute the following procedure on the VM:

login: root

ifconfig eth0 20.2.13.14 If you have not done so, create a virtual machine to represent the host H1: Create a VLAN interface on H2: linux32.redes H1 vconfig add eth0 3

Execute the following procedure on the VM: Create a configuration file for eth0.3: login: root cd /etc/sysconfig/network-scripts ifconfig eth0 20.1.13.14 vi ifcfg-eth0.3

Create a VLAN interface on H1: Edit the ifcfg-eth0.3 with the following content: vconfig add eth0 2 DEVICE=eth0.3 BOOTPROTO=dhcp Execute dhclient and check the IP address: ONBOOT=yes = dhclient eth0.2 ifconfig Create and edit the ifcfg-eth0 file as follows (there is no DHCP for eth0): To release an IP address, type: vi ifcfg-eth0 dhclient eth0.2 -r DEVICE=eth0 BOOTPROTO=static IPADDR=20.2.13.14 NETMASK=255.0.0.0 ifconfig eth0.3 13.14.1.2/24 ONBOOT=yes vconfig add eth0 4 ifconfig eth0.4 13.14.2.1/24 The next step is usually not necessary in non-virtualized sysctl -w net.ipv4.ip_forward=1 Linux environment. The image was created without an physical interface, and then some network configuration Activate the relay agent to redirect the incoming DHCP files were missing in installation. Create the /etc/sysconfig/ messages to G1: network in the UML machine: dhcrelay 13.14.1.1 vi /etc/sysconfig/network Additional commands on G1 VM: The file needs to include the following line: Include in G1 a to the subnet VM4: NETWORKING=yes route add -net 13.14.2.0/24 gw 13.14.1.2 Restart the network service and check the IP addresses: Additional commands on Host 2 VM: service network restart ifconfig Move host 2 to VLAN 4 to obtain a new IP address:

vconfig rem eth0.3 vconfig add eth0 4 dhclient -r ( the previous dhcp client instance) 5. SCENARIO 2 dhclient eth0.4

6. REPORT TO DELIVER THROUGH EUREKA

In this report you must include the information of two files used by the DHCP server ( i.e., the VM G1 ) :

The configuration file: /etc/dhcpd.conf The leases file: /var/lib/dhcpd/dhcpd.leases

Transfer both files to your directory in the espec and create a text file or .pdf file with this information.

scp /etc/dhcpd.conf [email protected]:. Scenario 2 evaluates the concept of relay agent as indicated scp /var/lib/dhcpd/dhcpd.leases [email protected]:. in the figure.

Create the virtual machine G2 to represent the relay agent: ALTERNATE METHOD TO TRANSFER FILES TO THE HOST ENVIRONMENT linux32.redes G2 There is an alternative method that can be used to transfer Execute the following commands on the new VM: files from the UML virtual machine to the HOST environment (espec) . login: root ifconfig eth0 20.3.13.14 Enter the following command in the HOST machine:

Create a VLAN interface on G2 mkdir /espec mount none /espec -t hostfs -o /home/rss vconfig add eth0 3 The directory /espec in the UML is now mounted and represents a directory in the espec. You can transfer the files using cp .

For example: cp vlan.cap /espec

The file will appear in the default directory (/home/rss ) in the host environment.

This mapping can also be done on espec server environment. In this case, however , you'd better first check your default directory in espec. Enter the following command in a terminal:

Replace the path after the " -o " parameter , as follows : mkdir /espec mount none /espec -t hostfs -o pwd_path