Skip to content

Commit

Permalink
Merge pull request #2 from jgabaut/main
Browse files Browse the repository at this point in the history
feat: add esercizi/..
  • Loading branch information
foxyseta committed Jun 5, 2023
2 parents 8a68bfa + 6978f1f commit 4037ac2
Show file tree
Hide file tree
Showing 89 changed files with 4,298 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ di sistemi T (28072) del Corso di Laurea in Ingegneria informatica.

## Presentazione

[Questo sito](https://csunibo.github.io/ng-laboratorio-amm-sistemi-t) elenca
[Questo sito](https://csunibo.github.io/ing-laboratorio-amm-sistemi-t) elenca
staticamente i contenuti della raccolta. Qui, documenti e presentazioni con
estensione `.md`, `.tex`, `.doc`, `.docx`, `.ppt` o `.pptx` sono automaticamente
convertiti in formato PDF.
Expand Down
Binary file modified appunti/note-jgabaut.odt
Binary file not shown.
1 change: 1 addition & 0 deletions esercizi/esercitazioni-jgabaut/DHCP/DHCP++/missing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Not done.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
auto eth1
iface eth1 inet dhcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- hosts: all
tasks:
- name: Add file .vimrc to home directory and set no-compatibility mode for vi
ansible.builtin.lineinfile:
path: /home/vagrant/.vimrc
line: 'set nocompatible'
state: present
create: yes

- name: Set a hostname
become: true
ansible.builtin.hostname:
name: Client1

- name: Fix allow-hotplug bug
become: true
ansible.builtin.replace:
path: /etc/network/interfaces
regexp: '^allow-hotplug'
replace: 'auto'

- name: Copy a new network configuration "interfaces" file into place, after passing validation with ifup
become: true
ansible.builtin.copy:
src: eth1
dest: /etc/network/interfaces.d/eth1
validate: /usr/sbin/ifup --no-act -i %s eth1
notify: Restart Networking

handlers:
- name: Restart Networking
become: true
ansible.builtin.service:
name: networking
state: restarted
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "las/bullseye64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network "private_network", virtualbox__intnet: "LAN1", auto_config: false

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.linked_clone = true
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
end
#
# View the documentation for the provider you are using for more
# information on available options.

# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
# config.vm.provision "shell", inline: <<-SHELL
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
# apt-get update
# apt-get install -y apache2
# SHELL
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
auto eth1
iface eth1 inet dhcp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
- hosts: all
tasks:

- name: Add file .vimrc to home directory and set no-compatibility mode for vi
ansible.builtin.lineinfile:
path: /home/vagrant/.vimrc
line: 'set nocompatible'
state: present
create: yes

- name: Set a hostname
become: yes
ansible.builtin.hostname:
name: Client2

- name: Fix allow-hotplug bug
become: true
ansible.builtin.replace:
path: /etc/network/interfaces
regexp: '^allow-hotplug'
replace: 'auto'

- name: Copy a new network configuration "interfaces" file into place, after passing validation with ifup
become: true
ansible.builtin.copy:
src: ./eth1
dest: /etc/network/interfaces.d/eth1
validate: /usr/sbin/ifup --no-act -i %s eth1
notify: Restart Networking

handlers:
- name: Restart Networking
become: true
ansible.builtin.service:
name: networking
state: restarted
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.

# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "las/bullseye64"

# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
# config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network "private_network", virtualbox__intnet: "LAN2", auto_config: false

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.linked_clone = true
# vb.gui = true
#
# # Customize the amount of memory on the VM:
# vb.memory = "1024"
end
#
# View the documentation for the provider you are using for more
# information on available options.

# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
# config.vm.provision "shell", inline: <<-SHELL
# apt-get update
# apt-get install -y apache2
# SHELL
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
auto eth1
iface eth1 inet static
address 10.10.1.1
netmask 255.255.255.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
auto eth2
iface eth2 inet static
address 10.10.2.1
netmask 255.255.255.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
- hosts: all
tasks:
- name: Add file .vimrc to home directory and set no-compatibility mode for vi
become: true
ansible.builtin.lineinfile:
path: /home/vagrant/.vimrc
line: 'set nocompatible'
state: present
create: yes

- name: Set a hostname
become: true
ansible.builtin.hostname:
name: Router

- name: Fix allow-hotplug bug
become: true
ansible.builtin.replace:
path: /etc/network/interfaces
regexp: '^allow-hotplug'
replace: 'auto'

- name: Copy a new network configuration "interfaces" file into place, after passing validation with ifup
become: true
ansible.builtin.copy:
src: ./eth1
dest: /etc/network/interfaces.d/eth1
validate: /usr/sbin/ifup --no-act -i %s eth1
notify: Restart Networking

- name: Copy a new network configuration "interfaces" file into place, after passing validation with ifup
become: true
ansible.builtin.copy:
src: ./eth2
dest: /etc/network/interfaces.d/eth2
validate: /usr/sbin/ifup --no-act -i %s eth2
notify: Restart Networking

- name: Install dnsmasq
become: true
ansible.builtin.apt:
name: dnsmasq
state: present
update_cache: yes

- name: Configure DHCP range for LAN1 and LAN2
become: true
ansible.builtin.blockinfile:
path: /etc/dnsmasq.conf
state: present
create: yes
block: |
interface=eth1
interface=eth2
dhcp-range=set:first,10.10.1.100,10.10.1.200,12h
dhcp-range=set:second,10.10.2.100,10.10.2.200,12h
dhcp-option=tag:second, 3, 10.10.2.15 #default route won't be set if we give a static route
dhcp-option=tag:second, 121, 10.10.1.0/24,10.10.2.1
dhcp-option=tag:first, 3, 10.10.1.15 #default route won't be set if we give a static route
dhcp-option=tag:first, 121, 10.10.2.0/24,10.10.1.1
notify: Restart Dnsmasq

- name: Set ipv4 forwarding on
become: true
ansible.posix.sysctl:
name: net.ipv4.ip_forward
value: '1'
sysctl_set: yes
state: present
reload: yes

handlers:
- name: Restart Networking
become: true
ansible.builtin.service:
name: networking
state: restarted

- name: Restart Dnsmasq
become: true
ansible.builtin.service:
name: dnsmasq
state: restarted
Loading

0 comments on commit 4037ac2

Please sign in to comment.