Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions ipv6-config/INFO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
## Instructions

Edit ipv6.json as follow:
`{"HOST":{"counter" : 5, "ipv6": ["ADDRESSES"],"dev": ["DEVICES"]}}`

- HOST = the name of the host in the topology
- counter = number of ADDRESSES and DEVICES (must be the same)
- ADDRESSES = list of IPv6 addresses to assign
- DEVICES = list of devices according to the related ipv6 address to be assigned

Let's sort ADDRESSES and DEVICES arrays according to the order, for example:
- ADDRESSES[i] is the IPv6 address to be assigned to the interface DEVICES[i]

## ipv6.json
This file contains the IPv6 addresses and the interfaces related to the addresses for each host.
If the topology changes this file has to be changed according to the topology in terms of:
- Name of each host
- IPv6 addresses of each host
- Interfaces related to each IPv6 address of each host

## routes.json
Like _ipv6.json_ this file contain the list of the routes to add to each host

`{"peo2":{"ROUTE":{"via": "NEXT_HOP_ADDRESS","dev": "DEVICE_TO_NEXT_HOP"}}}`
- ROUTE = the route to add
- NEXT_HOP_ADDRESS = the address of the next hop
- DEVICE_TO_NEXT_HOP = the host interface to NEXT_HOP_ADDRESS

## topology.json
This file contains the description of the desired topology of the network:

`{"counter":VALUE,"subnet0":"default","subnet(i)":{"network":"NET_ADDRESS","netmask":"NET_VALUE"}}`

- VALUE = number of the subnets
- SUBNET0 has to be keeped
- (i) = number of the subnet
- NET_ADDRESS = network address without netmask
- NET_VALUE = "/netmask"

This file has to be changed according to the topology of the network.


148 changes: 148 additions & 0 deletions ipv6-config/docs/ADDRESSING_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Mattia's README file

***
# Test using Bash commands
## Introduction
_First approach was the insert of IPv6 addresses via bash. According to the _IPv6_Manual_Strucure_
file I made SSH connection using MGM addresses from Linux machine to VMs and then I added IPv6 addresses to every machine. Finally I tested PP link between each Subnet
with ping6 command_



## BASH Command List
##### SSH to VMs
- `ssh <mgm_address>`
- `VMs SSH password = "1234"`
- `sudo su`

> Usually I obtain **su** rights to run some commands like **ip**.
> SSH connection are made according to Management addresses listed in the _IPv6_Manual_Strucure_ file
taken from the _Deploymet_Example_OUT_ file.

##### Adding new IPv6 address
- `ip -6 addr add <ip6address>/<length> dev <device>`

##### Removing existing IPv6 address
- `ip -6 addr del <ip6address>/<length> dev <device>`

##### Ping an IPv6 device
- `ping6 <ip6address>`



## Procedure and comments
1. Make SSH connection to every machine in the OSHI_Example_Project
- `ssh 10.255.255.1` **cro5**
- `ssh 10.255.254.1` **cro3**
- `ssh 10.255.253.1` **cro4**
- `ssh 10.255.252.1` **peo2**
- `ssh 10.255.251.1` **peo6**
- `ssh 10.255.250.1` **cer1**
- `ssh 10.255.249.1` **cer7**
- `ssh 10.255.248.1` **ctr8**

2. According to the IPv6 Structure proposed let's assign IPv6 addresses to VMs. Make attention to assign the address to the correct interface. According to the IPv4 topology we can assign IPv6 addresses to the same IPv4 interfaces such that we can support IPv6 to IPv4.
- `ip -6 addr add fd3c:9f20:5d73:01::01/64 dev vi1` **peo2** on Subnet1
- `ip -6 addr add fd3c:9f20:5d73:01::02/64 dev cer1-eth1` **cer1** on Subnet1

3. If I add a **new IPv6 address**, the system automatically creates the route for the network
- `ip -6 route show` **peo2**
- `fd3c:9f20:5d73:1::/64 dev vi1 proto kernel metric 256`

4. To fully support OSHI_Example to IPv6 we can add also MGM IPv6 addresses
- `ip -6 addr add fd3c:9f20:5d73:ffff::01/64 dev vi0` **cro5**
- (...)

5. Adding IPv6 to VMs we have to add IPv6 also to our Linux machine
- `ip -6 addr add fd3c:9f20:5d73:ffff::02/64 dev eth0`
- (...)

6. Ping in each PP Subnet using IPv6
- `ping6 fd3c:9f20:5d73:01::01` from **cer1** to **peo2**
- (...)

7. Adding loopback IPv6 address to _lo_ interface
- `ip -6 addr add <address>/128 dev lo`
- LO addresses are chosen according to the _IPv6_Manual_Structure file_


## Automatic allocation of IPv6 addresses

Using this script _MQ_ipv6_ssh_address.sh_ for the OSHI_Example_Project I can execute automatically commands described above.
The script uses

`sshpass -p <password>`

to connect using ssh to the target VM without asking the password known a priori;
then I concatenated the command

`ssh <address> <command>`

to give IPv6 address to the target VM; for example

`pass=1234`
`peo2="10.255.252.1"`
`sshpass -p $pass ssh $peo2 'sudo ip -6 addr add fd3c:9f20:5d73:01::01/64 dev vi1'`

The script also automatic assign LO IPv6 addresses to each VM

`sshpass -p $pass ssh $cro4 'sudo ip -6 addr add fdac::03/128 dev lo'`

***

# SSH Using Python

## Introduction
I rearranged the work made using bash commands in a python file that reads information from JSON files and makes SSH connection to assign IPv6 addresses.


## Procedure
1. I created a Python script that takes informations about topology from _overall_info.json_ placed in the _/tmp_ folder
- MGM addresses useful to make SSH connections

2. I takes other information about IPv6 addresses to be assigned to each host from _ipv6.json_ made by myself and that contains _Subnets_ and the structure of the _IPv6 Network_
- IPv6 Addresses
- Interfaces

3. I collected and I sorted following informations into some arrays
- Topology hosts _(pair of hosts each in the related subnet)_
- E.G. _(peo2,cer1,peo2,cro4,...)_
- MGM addresses of related hosts
- E.G. _(10.255.252.1, 10.255.250.1, 10.255.252.1, 10.255.253.1, ...)_
- IPv6 addresses of related hosts
- Interfaces of related hosts
Arrays are sorted such that the index [i] of any array is related to the same host:
IPv6[i] - DEV[i] - MGM[i] are related all to hosts[i]


4. In this way I could make SSH operation using _subprocess_ with one single command in a _for_ cycle :

`for i in range(0,len(mgm_sort)):
ssh=subprocess.Popen(['sshpass','-p',psswd,'ssh',mgm_sort[i],'sudo', 'ip', '-6', 'addr', 'add',ipv6[i] ,'dev', dev[i]])`


5. The same it is done about Loopback IPv6 addresses.

`for i in range(0,len(mgm)):
ssh=subprocess.Popen(['sshpass','-p',psswd,'ssh',mgm[i],'sudo', 'ip', '-6', 'addr', 'add',lo6[i] ,'dev', 'lo'])`

#### Comments

To make SSH connection it is use Python library _subprocess_
`shell=subprocess.Popen(['command','parameter','parameter'])`
***
# References
- [Deployment_Example_OUT](https://bitbucket.org/nip1617/ipv6-oshi-grpc/src/eea8669a79af1ee77b0258a44db807d3287eb8ce/ipv6/Deployment_OUT.txt?at=master)
- [IPv6_Structure](https://bitbucket.org/nip1617/ipv6-oshi-grpc/src/eea8669a79af1ee77b0258a44db807d3287eb8ce/ipv6/IPv6_Structure.txt?at=master)
- [IPv6 Private Addresses Structure](http://simpledns.com/private-ipv6.aspx)
- [RFC4193](http://www.rfc-editor.org/rfc/rfc4193.txt)

# Setup
- [MQ_ipv6_ssh_address.sh](https://bitbucket.org/nip1617/ipv6-oshi-grpc/src/eea8669a79af1ee77b0258a44db807d3287eb8ce/ipv6/MQ_ipv6_ssh_address.sh?at=master)
- [IPv6.py](https://bitbucket.org/nip1617/ipv6-oshi-grpc/src/eea8669a79af1ee77b0258a44db807d3287eb8ce/ipv6/ipv6.py?at=master)
- [Subnets.json](https://bitbucket.org/nip1617/ipv6-oshi-grpc/src/eea8669a79af1ee77b0258a44db807d3287eb8ce/ipv6/ipv6.json?at=master)
- [LoopbackIPv6.json](https://bitbucket.org/nip1617/ipv6-oshi-grpc/src/eea8669a79af1ee77b0258a44db807d3287eb8ce/ipv6/loopback6.json?at=master)
- [pingv6.py](https://bitbucket.org/nip1617/ipv6-oshi-grpc/src/4c223dda36a1b639785a0f3e4db3d5553196ce17/ipv6/pingv6.py?at=master)
****
# OSHI Example Topology
![OSHI_Example](https://bytebucket.org/nip1617/ipv6-oshi-grpc/raw/47e92648c943342635e0dbcfaa2c5edc1ed10fec/ipv6/media/OSHI_SUB.jpg?token=756d566ef420f40fa81e663e1b81db83b55ea08f)
Binary file added ipv6-config/docs/OSHI.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ipv6-config/docs/OSHI_SUB.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions ipv6-config/docs/ROUTING_Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Marco Pantanella - README

***

## Assegnazione delle rotte

Per l'assegnazione delle rotte, si consideri la figura seguente, rappresentante la topologia di rete:

![topology](https://bytebucket.org/nip1617/ipv6-oshi-grpc/raw/c6cd8ec6449792d6d034424071a7603835e1ad9c/ipv6/media/topologia.jpg?token=b0a16ce415c94493daf86e5e59310a50a8febf77)

basata sulla struttura e gli indirizzi IPv6 indicati nel file: [IPv6 Structure](https://bitbucket.org/nip1617/ipv6-oshi-grpc/raw/88e4668e8ce806db0f1f309bdafcb972522f7891/ipv6/IPv6_Structure.txt).

Ho creato inizialmente un script **JSON** ([routes.json](https://bitbucket.org/nip1617/ipv6-oshi-grpc/raw/88e4668e8ce806db0f1f309bdafcb972522f7891/ipv6/routes.json)) che indica per ogni gateway la rotta di default e le rotte alternative da me stabilite e contiene per ognuna di esse le variabili _via_ e _dev_.
Successivamente abbiamo implementato uno script ***_python_*** ([IPv6.py](https://bitbucket.org/nip1617/ipv6-oshi-grpc/raw/88e4668e8ce806db0f1f309bdafcb972522f7891/ipv6/ipv6.py)) che assegna gli indirizzi IPv6 e le rotte in base ai corrispettivi file _JSON_ ([address.json](https://bitbucket.org/nip1617/ipv6-oshi-grpc/raw/88e4668e8ce806db0f1f309bdafcb972522f7891/ipv6/ipv6.json)) e ([routes.json](https://bitbucket.org/nip1617/ipv6-oshi-grpc/raw/88e4668e8ce806db0f1f309bdafcb972522f7891/ipv6/routes.json)).
Prima di fare cio', vengono creati gli array per gli indirizzi di management, per gli indirizzi delle rotte di destinazione e infine per le interfacce (_via_) e i device (_dev_), con la seguente relazione:

for i in range(0,len(topo_ex)):
for j in range(0,len(subnetaddr)):
if subnetaddr[j] in route[topo_ex[i]]:
route_addr.append(subnetaddr[j])
mgm_route.append(mgm[i])
via.append(str(route[topo_ex[i]][subnetaddr[j]]['via'].decode('unicode_escape')))
dev_route.append(str(route[topo_ex[i]][subnetaddr[j]]['dev'].decode('unicode_escape')))

dove:

- `subnetddr = ['default','fd3c:9f20:5d73:01::/64','fd3c:9f20:5d73:02::/64','fd3c:9f20:5d73:03::/64','fd3c:9f20:5d73:04::/64','fd3c:9f20:5d73:05::/64','fd3c:9f20:5d73:06::/64','fd3c:9f20:5d73:07::/64','fd3c:9f20:5d73:08::/64','fd3c:9f20:5d73:09::/64','fd3c:9f20:5d73:0a::/64','fd3c:9f20:5d73:0b::/64']`
contiene gli indirizzi di tutte le subnet

- `topo_ex = ['peo2','peo6','cer1','cer7','cro3','cro4','cro5','ctr8']`
contiene i nodi della topologia di rete presa in considerazione

vengono dunque confrontati gli indirizzi delle subnet in subnetddr con gli indirizzi delle rotte di destinazione per ogni nodo nel file json routes.json e se presenti, vengono estrapolati i dati necessari per creare gli array:

- _mgm_route_ : contenente gli indirizzi di management per la connessione _ssh_
- _route_addr_: contenente gli indirizzi delle rotte di destinazione
- _via_: contenente gli indirizzi delle rotte di passaggio
- _dev_: contenente i device di uscita dai gateway

## SSH SESSION

Infine per assegnare le rotte, viene stabilita una connessione **SSH** su ogni _Virtual Machine_ , dove viene prima abilitato l' _IPv6 Forwarding_ con il seguente comando:

sudo sysctl -w net.ipv6.conf.all.forwarding=1

Successivamente vengono utilizzati nel seguente ciclo _for_ gli array precedentemente ricavati:

for i in range(0,len(mgm_route)):
ssh=subprocess.Popen(['sshpass','-p',psswd,'ssh',mgm_route[i],'sudo','ip','-6','r','add',route_addr[i],'via',via[i],'dev',dev_route[i]])
a questo punto, ogni nodo della rete avra' le rotte stabilite nel file _routes.json_ e viene confermato all'utente l'avvenuta configurazione con il messaggio "_configured successfully_".

#### Commenti
Per instaurare connessioni SSH in python è stata usata la libreria _subprocess_
`shell=subprocess.Popen(['command','parameter','parameter'])`

Binary file added ipv6-config/docs/topologia.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions ipv6-config/ipv6.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"peo2":{
"counter" : 5,
"ipv6": ["fdac::04/128","fd3c:9f20:5d73:01::01/64","fd3c:9f20:5d73:02::01/64","fd3c:9f20:5d73:04::01/64","fd3c:9f20:5d73:05::01/64"],
"dev": ["lo","vi1","vi2","vi3","vi4"]
},
"peo6": {
"counter" : 5,
"ipv6": ["fdac::05/128","fd3c:9f20:5d73:06::01/64","fd3c:9f20:5d73:08::01/64","fd3c:9f20:5d73:09::01/64","fd3c:9f20:5d73:0a::01/64"],
"dev": ["lo","vi1","vi2","vi3","vi4"]
},
"cer1":{
"counter" : 2,
"ipv6": ["fdac::06/128","fd3c:9f20:5d73:01::02/64"],
"dev": ["lo","cer1-eth1"]
},
"cer7": {
"counter" : 2,
"ipv6": ["fdac::07/128","fd3c:9f20:5d73:0a::02/64"],
"dev": ["lo","cer7-eth1"]
},
"cro3": {
"counter" : 5,
"ipv6": ["fdac::02/128","fd3c:9f20:5d73:03::01/64","fd3c:9f20:5d73:05::02/64","fd3c:9f20:5d73:06::02/64","fd3c:9f20:5d73:07::01/64"],
"dev": ["lo","vi1","vi2","vi3","vi4"]
},
"cro4": {
"counter" : 4,
"ipv6": ["fdac::03/128","fd3c:9f20:5d73:02::02/64","fd3c:9f20:5d73:07::02/64","fd3c:9f20:5d73:08::02/64"],
"dev": ["lo","vi1","vi2","vi3"]
},
"cro5": {
"counter" : 4,
"ipv6": ["fdac::01/128","fd3c:9f20:5d73:03::02/64","fd3c:9f20:5d73:04::02/64","fd3c:9f20:5d73:09::02/64"],
"dev": ["lo","vi1","vi2","vi3"]
},
"ctr8": {
"counter" : 2,
"ipv6": ["fdac::08/128","fd3c:9f20:5d73:0b::01/64"],
"dev": ["lo","ctr8-eth1"]
}
}
Loading