Setting a Static IP

Issues related to configuring your network
User avatar
TrevorH
Forum Moderator
Posts: 26862
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Setting a Static IP

Post by TrevorH » 2019/03/22 19:18:28

Do you have console access to this system or are you entirely reliant on ssh connections working?

If you are reliant on ssh then I would contact your supplier and ask them about making this change. You have a very odd setup there with what looks like an RFC1918 private address, presumably being supplied to you by DHCP but then you also have a number of non-RFC1918 addresses on the same interface. Since the only route you have if via the 192.168.1.x gateway, things might get very confused if you do this wrong and you might lock yourself out entirely.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

mark9090
Posts: 13
Joined: 2019/03/22 11:10:36

Re: Setting a Static IP

Post by mark9090 » 2019/03/22 19:20:48

TrevorH wrote:
2019/03/22 19:18:28
Do you have console access to this system or are you entirely reliant on ssh connections working?

If you are reliant on ssh then I would contact your supplier and ask them about making this change. You have a very odd setup there with what looks like an RFC1918 private address, presumably being supplied to you by DHCP but then you also have a number of non-RFC1918 addresses on the same interface. Since the only route you have if via the 192.168.1.x gateway, things might get very confused if you do this wrong and you might lock yourself out entirely.
I have direct physical console access.

User avatar
TrevorH
Forum Moderator
Posts: 26862
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Setting a Static IP

Post by TrevorH » 2019/03/22 19:27:39

Well I think you will need to contact your supplier anyway to find out what the ip range is that the DHCP server uses. You cannot pick an ip address from within that range as it might get handed out by the DHCP server to something else. You'll need to specify one that is not within the dhcp pool.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

mark9090
Posts: 13
Joined: 2019/03/22 11:10:36

Re: Setting a Static IP

Post by mark9090 » 2019/03/22 19:36:50

TrevorH wrote:
2019/03/22 19:27:39
Well I think you will need to contact your supplier anyway to find out what the ip range is that the DHCP server uses. You cannot pick an ip address from within that range as it might get handed out by the DHCP server to something else. You'll need to specify one that is not within the dhcp pool.
The DHCP server (my router) provides one IP from this range: 192.168.1.64 - 192.168.1.253 to the CentOS server over DHCP but the router also reports that the server is assigning the 81.143.9.98 - 81.143.9.101 range to itself statically. So the router and CentOS server are doing 2 different things at the same time.

I need the CentOS server to only use the 81.143.9.98 - 81.143.9.101 range. I have no clue how to achieve this safely.

lightman47
Posts: 975
Joined: 2014/05/21 20:16:00
Location: Central New York, USA

Re: Setting a Static IP

Post by lightman47 » 2019/03/22 19:45:42

Any chance the real issue is you want to be "visible"/addressable to the Internet?
Multple login IDs are not your friend when asking for help!

User avatar
TrevorH
Forum Moderator
Posts: 26862
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Setting a Static IP

Post by TrevorH » 2019/03/22 19:58:46

Post the content of all /etc/sysconfig/network-scripts/ifcfg-* files.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

mark9090
Posts: 13
Joined: 2019/03/22 11:10:36

Re: Setting a Static IP

Post by mark9090 » 2019/03/22 20:13:01

TrevorH wrote:
2019/03/22 19:58:46
Post the content of all /etc/sysconfig/network-scripts/ifcfg-* files.
ifcfg-enp2s0
TYPE="Ethernet"
BOOTPROTO="dhcp"
DEFROUTE="yes"
PEERDNS="yes"
PEERROUTES="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_PEERDNS="yes"
IPV6_PEERROUTES="yes"
IPV6_FAILURE_FATAL="no"
NAME="enp2s0"
UUID="0533dc19-71cc-4eec-9176-7fb5b75a6dc4"
DEVICE="enp2s0"
ONBOOT="yes"

ifcfg-lo
DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback

User avatar
TrevorH
Forum Moderator
Posts: 26862
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Setting a Static IP

Post by TrevorH » 2019/03/22 21:10:05

Since nothing there tells it to assign those ip addresses, you need to talk to the people that maintain your DHCP server.
CentOS 5 died in March 2017 - migrate NOW!
CentOS 6 goes EOL sooner rather than later, get upgrading!
Full time Geek, part time moderator. Use the FAQ Luke

mark9090
Posts: 13
Joined: 2019/03/22 11:10:36

Re: Setting a Static IP

Post by mark9090 » 2019/03/22 21:25:05

TrevorH wrote:
2019/03/22 21:10:05
Since nothing there tells it to assign those ip addresses, you need to talk to the people that maintain your DHCP server.
Presumably the following IP's are acquired by cPanel as denoted by cp on the end?
inet 81.143.9.98/24 brd 81.143.9.255 scope global enp2s0:cp1
valid_lft forever preferred_lft forever
inet 81.143.9.99/24 brd 81.143.9.255 scope global secondary enp2s0:cp2
valid_lft forever preferred_lft forever
inet 81.143.9.100/24 brd 81.143.9.255 scope global secondary enp2s0:cp3
valid_lft forever preferred_lft forever
inet 81.143.9.101/24 brd 81.143.9.255 scope global secondary enp2s0:cp4
The DHCP server (my router) is certainly not providing the above IP's as it indicating that the CentOS server is obtaining them statically.

mark9090
Posts: 13
Joined: 2019/03/22 11:10:36

Re: Setting a Static IP

Post by mark9090 » 2019/03/31 15:31:56

My ISP has provided me with the IP address of its DNS server, the gateway IP address, the correct net mask and the static IP address.

Presumably I can now put these details into the network config file like so?
/etc/sysconfig/network-scripts/ifcfg-enp2s0
IPADDR=81.143.9.98
NETMASK=255.255.255.248
GATEWAY=81.145.9.102
DNS1=194.72.9.34
I have already done a dummy run of the above on my Apple Time Capsule and the Time Capsule gains internet access with the static IP of 81.143.9.98 so presumably no hiccups will arise if I input the same static IP details into /etc/sysconfig/network-scripts/ifcfg-enp2s0 on CentOS?

Post Reply

Return to “CentOS 7 - Networking Support”