Profili netctl


Guida alla creazione e all’abilitazione dei profili di rete netctl

NETCTL è un tool a riga di comando che consente di gestire le proprie connessioni di rete tramite la creazione e l’abilitazione di profili di rete.

ATTENZIONE!! Se si stanno utilizzando altri tool per la gestione di reti, sarà necessario arrestare e disabilitare all’avvio i rispettivi demoni.

Esempio per Network Manager:

# systemctl stop network-manager
-----------------------------------
# systemctl disable network-manager

Per creare profili per le nostre connessioni di rete sarà sufficiente modificare i file di esempio contenuti in /etc/netctl/examlpes. Digitare il seguente comando per visualizzare l’elenco dei file di esempio contenuti in /etc/netctl/example:

$ ls -la /etc/netctl/example/ 
------------------------------------------------------
drwxr-xr-x 2 root root 4096 13 giu 17.13 .
drwxr-xr-x 5 root root 4096 20 ott 21.58 ..
-rw-r--r-- 1 root root 143 13 giu 17.13 bonding
-rw-r--r-- 1 root root 193 13 giu 17.13 bridge
-rw-r--r-- 1 root root 346 13 giu 17.13 ethernet-custom
-rw-r--r-- 1 root root 222 13 giu 17.13 ethernet-dhcp
-rw-r--r-- 1 root root 437 13 giu 17.13 ethernet-static
-rw-r--r-- 1 root root 315 13 giu 17.13 macvlan-dhcp
-rw-r--r-- 1 root root 432 13 giu 17.13 macvlan-static
-rw-r--r-- 1 root root 624 13 giu 17.13 mobile_ppp
-rw-r--r-- 1 root root 125 13 giu 17.13 openvswitch
-rw-r--r-- 1 root root 772 13 giu 17.13 pppoe
-rw-r--r-- 1 root root 239 13 giu 17.13 tunnel
-rw-r--r-- 1 root root 177 13 giu 17.13 tuntap
-rw-r--r-- 1 root root 198 13 giu 17.13 vlan-dhcp
-rw-r--r-- 1 root root 326 13 giu 17.13 vlan-static
-rw-r--r-- 1 root root 176 13 giu 17.13 wireless-open
-rw-r--r-- 1 root root 413 13 giu 17.13 wireless-wep
-rw-r--r-- 1 root root 423 13 giu 17.13 wireless-wpa
-rw-r--r-- 1 root root 181 13 giu 17.13 wireless-wpa-config
-rw-r--r-- 1 root root 409 13 giu 17.13 wireless-wpa-configsection
-rw-r--r-- 1 root root 290 13 giu 17.13 wireless-wpa-static

Scegliere il profilo desiderato e procedere copiando e rinominando il file in modo arbitrario nel percorso /etc/netctl/:

# cp /etc/netctl/examples/wireless-open /etc/netctl/<nome_profilo>

Modificare il file copiato inserendo i parametri della rete wifi a cui si desidera connettersi:

File originale:

# nano /etc/netctl/<nome_profilo>
----------------------------------------------
Description='A simple open wireless connection'
Interface=wlan0
Connection=wireless
Security=none
ESSID='MyNetwork'
IP=dhcp
# Uncomment this if your ssid is hidden
#Hidden=yes

Modificarlo inserendo iil nome della propria interfaccia wifi, e il nome EESID della rete wifi:

Interface=wls1
Connection=wireless
Security=none
ESSID=ReteWiFi
IP=dhcp
# Uncomment this if your ssid is hidden
#Hidden=yes

Si può eliminare la riga ‘Description=’. Salvare e chiudere il file.

Testare il funzionamento del profilo avviandolo manualmente:

# netctl start <nome_profilo>

Se tutto procede senza problemi, è possibile abilitare il profilo al boot con il seguente comando:

# netctl enable <nome_profilo>

Se fosse necessario, per arrestare o riavviare un profilo digitare i seguenti comandi:

# netctl stop <nome_profilo>
-------------------------------
# netctl restart <nome_profilo>

Per visualizzare lo stato di un profilo:

# netctl status <nome_profilo>

Per visualizzare l’elenco dei profili netctl:

# netctl list

Per disabilitare al boot un profilo:

# netctl disable <nome_profilo>

Alri esempi:

Connessione wirelles WPA:

# cp /etc/netctl/examples/wireless-wpa /etc/netctl/<nome_profilo>
-----------------------------------------------------------------
# nano /etc/netctl/<nome_profilo>
-----------------------------------------------------------------
Description='A simple WPA encrypted wireless connection'
Interface=wlan0
Connection=wireless
Security=wpa
IP=dhcp
ESSID=ReteWiFi
# Prepend hexadecimal keys with \"
# If your key starts with ", write it as '""<key>"'
# See also: the section on special quoting rules in netctl.profile(5)
Key=chiaveWPA
# Uncomment this if your ssid is hidden
#Hidden=yes
# Set a priority for automatic profile selection
#Priority=10

Connessione WPA ip statico

# cp /etc/netctl/examples/wireless-wpa-static /etc/netctl/<nome_profilo>
------------------------------------------------------------------------
# nano /etc/netctl/<nome_profilo>
------------------------------------------------------------------------
Interface=wlan0
Connection=wireless
Security=wpa
ESSID=ReteWiFi
Key=chiaveWPA
IP=static
Address=192.168.1.23/24
Gateway=192.168.1.1
DNS=192.168.1.1
# Uncomment this if your ssid is hidden
#Hidden=yes