1

How do I configure a CentOS7 server to connect to the internet and be known as a specific IPv4 address in the form of: aa.aa.aaa.aa2?


HERE ARE THE DETAILS (Updated 2/27/2017):


Cable Modem

A Cisco DPC3941B (see link) router from an internet access provider has a Gateway IP aa.aa.aaa.aa6, and has several IP addresses allocated to it in the form of aa.aa.aaa.aa1, aa.aa.aaa.aa2, aa.aa.aaa.aa3, aa.aa.aaa.aa4, and aa.aa.aaa.aa5. It also has subnet mask 255.255.255.248 and DNS bb.bb.bb.bb, bb.bb.cc.cc.

CentOS 7 Config

nmcli con show gives results including eno1 uuid 802-3-ethernet eno1.

nmcli con show eno1 gives a lot of output, including:

IPV4.ADDRESS[1]:  aa.aa.aaa.aa2/29  
IPV4.GATEWAY:     aa.aa.aaa.aa6  
IPV4.DNS[1]:      bb.bb.bb.bb  
IPV4.DNS[2]:      bb.bb.cc.cc  

But yet when I ping google.com from the same terminal, the response is connect: Network is unreachable. And when I try to Putty to aa.aa.aaa.aa2 from another computer, the connection times out without connecting. Similarly, typing ping aa.aa.aaa.aa2 from another computer also times out with 0% packet return.

In case this is a firewall issue, I typed firewall-cmd --zone=public --list-all and got:

public (default, active)  
  interfaces:eno1  
  sources:  
  services: dhcpv6-client ssh  
  ports:  
  masquerade: no
  forward-ports: 
  icmp-blocks  
  rich rules:  

How A Windows Machine Is Configured to Do The Same Thing Successfully

To rule out the possibility that the problem might be caused by the cable modem, I connected a Windows laptop to the modem with the following steps outlined below, and am able to connect to the internet and be seen as aa.aa.aaa.aa1 when using the Windows laptop through a different ethernet cable connected to the same modem.

Here are the steps that get the Windows laptop to connect to the internet as aa.aa.aaa.aa1 through the same cable modem:

1.  Control Panel > Network and Internet > Network and Sharing Center    
2.  Click “Change Adapter Settings”  
3.  Right click on “Ethernet 2” connection and click on “Properties”  
4.  Select “Internet Protocol Version 4 (TCP/IPv4)”  
5.  Then click on “Properties” Button to open the target dialog box:  
    a.  In the default state, the “Obtain IP address automatically” option is checked  
    b.  To claim a specific IP instead, click “Use The Following IP Address” and enter the following information:  
            i.  IP Address:  aa.aa.aaa.aa1  
            ii. Subnet Mask: 255.255.255.248  
            iii.    Default Gateway: aa.aa.aaa.aa6  
            iv. Preferred DNS Server: bb.bb.bb.bb  
            v.  Alternate DNS Server: bb.bb.cc.cc  
            vi. Check the “Validate Settings on Exit” option.  
            vii.    Click OK  
6.  Click on any other open dialog boxes to return computer to normal state  

Pinging The Cable Modem's Local IP

The Windows command prompt is able to successfully ping the Cable modem by typing ping 10.x.x.x, which is the local IP for the cable modem.

But when I type the identical ping 10.x.x.x from the CentOS 7 server's terminal, the response is connect: Network is unreachable.

Ethernet cable lit on both ends

The Ethernet jack on the server is lit up indicating that it is connected, and the Ethernet jack on the other end of the server cable attached to the cable modem is also lit up indicating that it is connected. So there is an electrical connection between the CentOS 7 server and the cable modem.

The problem seems isolated to the CentOS 7 config.

Setting Up A Route To The Cable Modem From CentOS

The Internet Service Provider gave this link containing information about how to set up a connection between a generic machine and the local modem. The link is for a different kind of connection, but the ISP said it could be adapted.

  • This sounds as if the "gateway" is in effect a switch and not a "router". Given the pattern xx.xx.xxx.xxx can you confirm that the first 2 digits are not 10? Does something like the phrase "static ip address allocation" appear in the information sent to you by the ISP? with the xx.xx.xxx.xxx are the first 7 digits the same for each of the addresses? How many addresses are there (hopefully 2, 6, 14, 30, in general a number of the form 2**n-2)? – icarus Dec 29 '16 at 20:39
  • @icarus The first 2 digits are NOT 10. The first 7 digits are the same for all of the ip addresses, and for the gateway IP. The gateway IP can be pinged directly from outside in the internet. Also, when I hook up a Windows box to the router and use the control panel to set one of the allocated IP addreses, I am able to ping that IP from the outside internet also. This is a situation of buying 5 IP addresses along with an internet access account. Does this clarify? – CodeMed Dec 29 '16 at 20:44
  • Yes it clarifies. So you want to do essentially the same with the Centos7 boxes as you do with the Windows box. In the windows box you needed to put in the ip address, the netmask and the gateway. With Linux this is a 2 step affair. Step one sets the address and netmask, and step two sets the gateway. (The 5 addresses sound good, I should have said 2**n-3, so 1, 5,13, 29 are for you and one more is the gateway, the other 2 missing addresses are the address for the lan itself and the broadcast address). – icarus Dec 29 '16 at 20:56
  • @icarus So if I hook up a keyboard and a monitor to one of the CentOS 7 servers, what specific sequence of commands do I type in to accomplish the desired results stated in the OP? – CodeMed Dec 29 '16 at 21:03
  • If you can reboot the servers then the easy thing to do is edit /etc/network/interfaces and reboot. You need to know the name of your interface. If you run ip -o addr show then there will be a series of lines, like "2: eth0: inet....". You want the "eth0" part. Ignore the name "lo". You want to add/alter a set of 4 lines. iface eth0 inet static address xx.xx.xxx.xxx netmask 255.255.255.248 gateway xx.xx.xxx.xxx the last being the gateway ip address. It might be that you should put these 4 lines into a /etc/network/interfaces.d directory in a file named after the interface. – icarus Dec 29 '16 at 21:13
0

Long story short, need to configure a static IP address on Centos7, which is covered in the FAQ. Once this was done everything worked.

  • Links change, so the best practice on this site is to copy the relevant portions of what is on the linked page into your answer, and then to provide the link to give credit to the original resource. I am marking yours as accepted because you spent so much time helping me find the answer, but another reader would have to spend a very link time sorting through the comments and chat and your link to figure out how to solve a similar problem, because your answer is so terse. – CodeMed Feb 28 '17 at 23:37
  • @CodeMed Feel free to edit my answer. – icarus Mar 1 '17 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.