Change network settings on the server
Change network settings via Rescue
- Ubuntu
- Debian
- CentOS
-
Open the
netplan
utility configuration file with thevi
text editor:vi /etc/netplan/01-netcfg.yaml
or
vi /etc/netplan/50-cloud-init.yaml
-
For the desired interface, change the
addresses
andgateway4
values to the new IP address and gateway.The configuration file is written in YAML, a tab- and space-sensitive language. Fill it out similar to how it was filled out previously.
Example configuration file
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
addresses: [178.132.202.202.35/28]
gateway4: 178.132.202.33
nameservers:
addresses: [188.93.16.19, 188.93.17.19]Here:
eth0
is the name of the network interface;addresses: [178.132.202.202.35/28]
— Server IP address with subnet mask;gateway4: 178.132.202.33
is the subnet gateway.
-
Press the `ESC key.
-
Exit the
vi
text editor with the changes saved::wq
-
Check the configuration file for errors and apply the configuration:
netplan --debug generate
netplan apply -
In Control Panel, go to Servers and colocation → Servers.
-
Open the server page → Ports tab.
-
In the Internet port bar, click .
-
In the VLAN field, replace the value General with the value of the allocated VLAN. You can view the VLAN of a dedicated subnet in Control Panel under Servers and colocation → Network → Subnets tab.
-
Click Configure.
-
Return the previous server boot template or reboot the server from the OS. When you reboot the server from the OS, the boot template will automatically change to the one that was set before change server boot template.
-
Open the network interfaces configuration file with the
vi
text editor:vi /etc/network/interfaces
-
For the desired interface, change the
address
andgateway
values to the new IP address and gateway.Example configuration file
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 178.132.202.35
netmask 255.255.255.255.0
gateway 178.132.202.33
dns-nameserver 188.93.16.19 188.93.17.19Here:
eth0
is the name of the network interface;address 178.132.202.35
is the IP address of the server;gateway 178.132.202.33
is the subnet gateway.
-
Press the `ESC key.
-
Exit the
vi
text editor with the changes saved::wq
-
Clear all network addresses assigned to the network interface:
ip addr flush <eth_name>
Specify
<eth_name>
is the name of the network interface whose settings you changed in step 4. -
Restart the network:
service networking restart
-
In Control Panel, go to Servers and colocation → Servers.
-
Open the server page → Ports tab.
-
In the Internet port bar, click .
-
In the VLAN field, replace the value General with the value of the allocated VLAN. You can view the VLAN of a dedicated subnet in Control Panel under Servers and colocation → Network → Subnets tab.
-
Click Configure.
-
Return the previous server boot template or reboot the server from the OS. When you reboot the server from the OS, the boot template will automatically change to the one that was set before change server boot template.
-
Display information about the network interfaces:
ip a
-
Open the configuration file with the
vi
text editor:vi /etc/sysconfig/network-scripts/ifcfg-<eth_name>
Specify
<eth_name>
— the name of the network interface whose settings you want to change. -
Change the
IPADDR
andGATEWAY
values to the new IP address and gateway.Example configuration file
NAME="eth0"
ONBOOT=yes
NETBOOT=yes
BOOTPROTO=static
HWADDR="00:25:90:7a:d3:df"
IPADDR="178.132.202.35"
NETMASK="255.255.255.255.0"
GATEWAY="178.132.202.33"
TYPE=Ethernet
NMCONTROLED=yesHere:
eth0
is the name of the network interface;IPADDR="178.132.202.35"
— IP address of the server;GATEWAY="178.132.202.33"
is the subnet gateway.
-
Press the `ESC key.
-
Exit the
vi
text editor with the changes saved::wq
-
Restart the network:
systemctl restart network
-
In Control Panel, go to Servers and colocation → Servers.
-
Open the server page → Ports tab.
-
In the Internet port bar, click .
-
In the VLAN field, replace the value General with the value of the allocated VLAN. You can view the VLAN of a dedicated subnet in Control Panel under Servers and colocation → Network → Subnets tab.
-
Click Configure.
-
Return the previous server boot template or reboot the server from the OS. When you reboot the server from the OS, the boot template will automatically change to the one that was set before change server boot template.
Change network settings via WinPE
Network settings can be restored if you in the network interface settings:
- clicked on DHCP address acquisition;
- configured the wrong IP address.
Restore network settings for Windows Server access is done through the registry. Before making changes, access the registry from WinPE and back up the partition where the system and registry files are located, usually C:Windows/System32/config/SYSTEM
.
-
Open
cmd
. -
Output information about the settings of the network interfaces:
ipconfig /all
-
Memorize or copy the value of the description field for the desired interface.
-
Open the Registry Editor program:
regedit
-
Mount the branch with the system and registry files to the HKEY_LOCAL_MACHINE partition:
- highlight the HKEY_LOCAL_MACHINE section;
- from the File menu, select Load hive;
- in the dialog box, select the directory where the system and registry files are located, usually
C:Windows\system32\config\SYSTEM
; - enter the name with which the loaded branch will be mounted in HKEY_LOCAL_MACHINE and click Open.
-
In the mounted branch, locate the desired interface:
- expand the registry section:
HKEY_LOCAL_MACHINE\branch name\ControlSet001\Control\Class\{4d36e972-e325-11ce-bfc1-08002be10318}
- The list will contain a list of network interfaces from 0000 to 0013, find the interface that has the description from step 4 in the Driver Desc parameter;
- save the value of the NetCfgInstanceId field of the found interface.
-
Change the values of the interface parameters:
- go to the registry section:
HKEY_LOCAL_MACHINE\branch_name\ControlSet001\Services\Tcpip\Parameters\Interfaces\NetCfgInstanceId field value.
- edit the values of the parameters:
DefaultGateway
;IPAddress
;NameServer
;SubnetMask
. If you are not using DHCP —EnableDHCP
at0
, if you are using it — at1
. The correct values can be viewed in Control Panel: under Servers and colocation → Server page → Network tab → click on the desired subnet.
-
Unload the hive by selecting it and choosing Unload hive from the File menu.
-
Return the previous server boot template or reboot the server from the OS. When you reboot the server from the OS, the boot template will automatically change to the one that was set before change server boot template.