L’unico modo di collegarsi era attraverso la connessione alla console via web. Adesso riporto i passi effettuati per il cambio ip a seconda del sistema operativo installato.
- Ubuntu 14.04.5 LTS
Utilizzo il comando ip addr show per vedere l’indirizzo IP vecchio che sarà da aggiornare
alex@vegeta:~$ ip addr show
Poi usando un utente amministrativo (direttamente root o con sudo) andrò a modificare il file /etc/network/interfaces sostituendo il vecchio IP (38.240.2.85) con quello nuovo indicato nel pannello di controllo e anche il relativo gateway (38.240.2.1)
sudo su - cd /etc/network root@vegeta:~# cd /etc/network root@vegeta:/etc/network# ls -lrt totale 24 drwxr-xr-x 2 root root 4096 apr 27  2018 interfaces.d -rw-r--r-- 1 root root   82 ott 4 2018 interfaces drwxr-xr-x 2 root root 4096 set 18 17:13 if-up.d drwxr-xr-x 2 root root 4096 set 18 17:13 if-pre-up.d drwxr-xr-x 2 root root 4096 set 18 17:13 if-post-down.d drwxr-xr-x 2 root root 4096 set 18 17:13 if-down.d
Cambio dei permessi del file interfaces in modo da permettere la modifica
chmod 755 interfaces
Edit del file interfaces (con vi o nano)
vi interfaces
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 64.137.xx.xx gateway 64.137.xx.1 netmask 255.255.255.0 sysctl kernel.hostname=c758508757-cloudpro-866264567.cloudatcost.com hostname c758508757-cloudpro-866264567.cloudatcost.com dns-nameservers 8.8.8.8
Ripristino dei permessi del file interfaces
chmod 644 interfaces
Restart del servizio di rete o reboot del server per recepire il nuovo IP. Ora è il server è raggiungibile via ssh e non solo dalla console ed è possibile fare gli aggiornamenti dei pacchetti
sudo /etc/init.d/networking restart
https://www.cyberciti.biz/faq/ubuntu-linux-change-ip-address/
- Ubuntu 18.04.3 LTS
Per la versione 18.04 di Ubuntu bisogna usare l’utility netplan.
Di seguito i comandi eseguiti per modificare il file 50-cloud-init.yaml
alex@raven:~$ sudo su - [sudo] password for alex: root@raven:~# cd /etc/netplan/ root@raven:/etc/netplan# ls -lrt total 8 -rw-r--r-- 1 root root 194 Jun 27 2018 01-netcfg.yaml -r-xr-xr-x 1 root root 321 Feb 9 15:17 50-cloud-init.yaml root@raven:/etc/netplan# cat 50-cloud-init.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: ens32: dhcp4: no dhcp6: no addresses: [64.137.xx.xx/24] gateway4: 64.137.xx.1 nameservers: addresses: [8.8.8.8,8.8.4.4] root@raven:/etc/netplan# netplan apply root@raven:/etc/netplan# ip a
- CentOS 7.5
Riporto direttamente i comandi che ho eseguito:
[alex@starfire ~]$ sudo su - [sudo] password di alex: </pre> <pre>[alex@starfire ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens32: <ROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:50:56:91:66:ca brd ff:ff:ff:ff:ff:ff inet 38.240.190.182/24 brd 38.240.190.255 scope global noprefixroute ens32 valid_lft forever preferred_lft forever inet6 fe80::250:56ff:fe91:66ca/64 scope link valid_lft forever preferred_lft forever </pre> <pre>[alex@starfire ~]# cd /etc/sysconfig/network-scripts/ [alex@starfire network-scripts]# ls -lrt totale 232 -rwxr-xr-x. 1 root root 1876 17 mar 2017 ifup-TeamPort -rwxr-xr-x. 1 root root 1755 17 mar 2017 ifup-Team -rwxr-xr-x. 1 root root 1556 17 mar 2017 ifdown-TeamPort -rwxr-xr-x. 1 root root 1621 17 mar 2017 ifdown-Team -rw-r--r--. 1 root root 31027 29 mar 2019 network-functions-ipv6 -rw-r--r--. 1 root root 20671 29 mar 2019 network-functions -rwxr-xr-x. 1 root root 5419 29 mar 2019 init.ipv6-global -rwxr-xr-x. 1 root root 1836 29 mar 2019 ifup-wireless -rwxr-xr-x. 1 root root 2711 29 mar 2019 ifup-tunnel -rwxr-xr-x. 1 root root 3303 29 mar 2019 ifup-sit -rwxr-xr-x. 1 root root 2001 29 mar 2019 ifup-routes -rwxr-xr-x. 1 root root 4154 29 mar 2019 ifup-ppp -rwxr-xr-x. 1 root root 4997 29 mar 2019 ifup-post -rwxr-xr-x. 1 root root 1064 29 mar 2019 ifup-plusb -rwxr-xr-x. 1 root root 650 29 mar 2019 ifup-plip -rwxr-xr-x. 1 root root 11893 29 mar 2019 ifup-ipv6 -rwxr-xr-x. 1 root root 12075 29 mar 2019 ifup-ippp -rwxr-xr-x. 1 root root 13475 29 mar 2019 ifup-eth -rwxr-xr-x. 1 root root 910 29 mar 2019 ifup-bnep -rwxr-xr-x. 1 root root 12415 29 mar 2019 ifup-aliases -rwxr-xr-x. 1 root root 1462 29 mar 2019 ifdown-tunnel -rwxr-xr-x. 1 root root 1456 29 mar 2019 ifdown-sit -rwxr-xr-x. 1 root root 870 29 mar 2019 ifdown-routes -rwxr-xr-x. 1 root root 1068 29 mar 2019 ifdown-ppp -rwxr-xr-x. 1 root root 2130 29 mar 2019 ifdown-post -rwxr-xr-x. 1 root root 4540 29 mar 2019 ifdown-ipv6 -rwxr-xr-x. 1 root root 781 29 mar 2019 ifdown-ippp -rwxr-xr-x. 1 root root 6532 29 mar 2019 ifdown-eth -rwxr-xr-x. 1 root root 654 29 mar 2019 ifdown-bnep -rw-r--r--. 1 root root 254 29 mar 2019 ifcfg-lo lrwxrwxrwx. 1 root root 24 22 set 10.17 ifdown -> ../../../usr/sbin/ifdown lrwxrwxrwx. 1 root root 11 22 set 10.17 ifdown-isdn -> ifdown-ippp lrwxrwxrwx. 1 root root 22 22 set 10.17 ifup -> ../../../usr/sbin/ifup lrwxrwxrwx. 1 root root 9 22 set 10.17 ifup-isdn -> ifup-ippp -r-xr-xr-x. 1 root root 132 15 feb 15.50 ifcfg-ens32 [root@starfire network-scripts]# chmod 755 ifcfg-ens32 [root@starfire network-scripts]# cat ifcfg-ens32 DEVICE=ens32 BOOTPROTO=static ONBOOT=yes IPADDR=38.240.190.182 NETMASK=255.255.255.0 GATEWAY=38.240.190.1 DNS1=8.8.8.8 DNS2=8.8.4.4 [root@starfire network-scripts]# chmod 555 ifcfg-ens32 </pre> <pre>[root@starfire network-scripts]# service network restart Restarting network (via systemctl): [ OK ]