0

I just installed CentOS 7 and configured my network as given here

When I did cat /etc/resolv.conf, I got:

# Generated by NetworkManager
search home
nameserver <IP address>

So I guess I have only one DNS and included only DNS1="" in the /etc/sysconfig/network-scripts/ifcfg-enp5s0 file.

When I do route -n, I get:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         <IP Address-1>      0.0.0.0         UG    100    0        0 enp5s0
<IP Address-2>      0.0.0.0         255.255.255.0   U     100    0        0 enp5s0

I am assuming my gateway is IP Address-1 above and updated the same in config file. Now my /etc/sysconfig/network-scripts/ifcfg-enp5s0 looks like:

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="enp5s0"
UUID="ae988f3f-1fdb-4613-a7bc-c43fb8076c15"
DEVICE="enp5s0"
ONBOOT="yes"
IPADDR="172.XX.X.XX"
PREFIX="24"
GATEWAY="172.XX.X.X"
DNS1="172.XX.X.X" 
DNS2="172.XX.X.X"

Both DNS1, DNS2 are same as Gateway.

My /etc/resolv.conf looks like: # Generated by NetworkManager domain hom search home nameserver 172.XX.X.X

After updating all these values and naming my machine centos7 in /etc/hostname file, I am not able to connect to the machine with ssh user_name@hostname but ssh [email protected] works. Also, after the machine logs in, the prompt looks like: [user_name@hostname ~]$

We do have other machines running Centos 6 and donot have such issues. We use host names for remote connection to those. I am having this problem only with centOS 7. Also, when i do host <IP ADDRESS>, all other machines show their hostnames but Centos 7 doesnot. It just says new-host-23.home

Not sure if this is a machine issue or a DNS issue. I did not find my solution in another similar question on Stack overflow. Someone please help me.

1
  • are you able to ping centos7? Jul 27, 2016 at 20:33

2 Answers 2

0

First, make sure if the following value is correct:

domain hom

Then, perform a simple network test on your SSH client machine:

nslookup <centos7_hostname>

A positive result should be similar as follow:

Non-authoritative answer:
Name:    www.google.com
Addresses:  216.58.221.100

If you cannot get a successful response from NSLOOKUP, you need to check if a relevant DNS record is stored at your local DNS server.

2
  • Thanks, I got something strange here: nslookup <centos7_hostname> gives: Name: centos7 Address 1: some other IP Address. the IP Address I am getting here is not what I see when I do ifconfig on the centos7 machine.
    – kskp
    Jul 28, 2016 at 14:43
  • Then you have to check the record of your DNS server to see if it is pointed to the correct IP address. Jul 29, 2016 at 2:21
0

You have put:

BOOTPROTO="dhcp"

But it should be:

BOOTPROTO="none"

With your config, you are still using DHCP, so it is not strange that you get another IP... because your IP settings is ignored.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .