PDA

View Full Version : How to change Linux dedicate server IP to another one from assigned subnet



Fli
07-08-2017, 05:24 PM
Dedicated serve provider assigned two IPv4 subnets to the server and i wanted to use IP from second subnet as my server primary IP.


1.2.3.192/27 Primary VLAN
9.8.7.136/29 DDoS Protected

I modified networking configuration like this:

nano /etc/network/interfaces
(centos /etc/sysconfig/network or /etc/sysconfig/network-scripts/ifcfg-*)

commented out/removed lines beginning "address" and "gateway" because these contained IPs from first subnet which i did not wanted to use. And as "address" used third IP from the subnet of my choice. Example they assigned 9.8.7.136/29 subnet, so the third IP is 9.8.7.138 , the second IP is gateway. so i updated interfaces file that way. One can use also other IP, but not first two IPs of the subnet.

vi /etc/hosts

replaced IP too there. I also updated hostname there and in my server provider control panel set reverse DNS record for the new IP to match this hostname of my choice.
Example line: 192.168.15.77 prox4m1.proxmox.com prox4m1 pvelocalhost

then update also /etc/hostname

service networking restart

and from now on i was able to login my server via different IP i set above.

If you have fix for this setup, please kindly share. Thank You

radwebhosting
07-18-2017, 03:15 AM
Edit the /etc/sysconfig/network-scripts/ifcfg-eth0 and ensure the IPs are properly bound to the NIC (https://radwebhosting.com/client_area/knowledgebase/118/How-to-Bind-Additional-IPs-to-Network-Interface-Card---CentOS.html).