How to change server IP address from DHCP to static?

From Kolmisoft Wiki
Jump to navigationJump to search

WARNING, license should be updated after changing IP, so please contact Kolmisoft support before changing IP.

1. Gather the required information

Static IP addresses are assigned for network interfaces. You can find out all your network interfaces names using this command:

ifconfig

You have to pick the one that has the address you already know. For example we have a server with such interfaces:


eth0      Link encap:Ethernet  HWaddr 00:22:15:98:30:27
          inet addr:192.168.0.108  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::222:15ff:fe98:3022/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:491112 errors:0 dropped:0 overruns:0 frame:0
          TX packets:452621 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:553199357 (527.5 MiB)  TX bytes:48077932 (45.8 MiB)
          Interrupt:24 Base address:0x6000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:7039 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7039 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1892466 (1.8 MiB)  TX bytes:1892466 (1.8 MiB)

We see that current IP address is 192.168.0.108, network mask: 255.255.255.0

DNS settings are located in a configuration file /etc/resolv.conf:

bash-4.1$  cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 213.197.128.71
nameserver 213.197.150.130



2. Change IP address to static

Open a configuration file with a desired Linux editor (for example nano, mcedit, vi) which matches your network interface name, in this example we will use eth0:

mcedit /etc/sysconfig/network-scripts/ifcfg-eth0

You will see a configuration file like this:

DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="00:22:15:98:30:27"
NM_CONTROLLED="yes"
ONBOOT="yes"

You have to change it to look like this:

Warning!!! You must be sure that the settings below are correct or you will shoot yourself to the leg - you will be disconnected and will not be able to connect again when configuring remotely

DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=00:22:15:98:30:27  # <-- !!!!leave this setting as is in your current configuration, it will be different than provided here!!!
NETMASK=255.255.255.0	   # set here your netmask	
IPADDR=192.168.0.22	   # set here your desired STATIC IP ADDRESS		
GATEWAY=192.168.0.1	   # set here your desired Gateway address
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes

Warning!!! You must be sure that the settings above are correct or you will shoot yourself to the leg - you will be disconnected and will not be able to connect again when configuring remotely

3.Restarting the network

When you are sure that you set up the network correctly - save the changes to an opened file and restart your server networking using this command:

/etc/init.d/network restart



Other settings that have to be changed

When changing the server address you also must make additional changes documented here