Cannot ping centos7 host

22,930

Solution 1

nmap will give following output though both hosts are not in same subnet !

ashish@ashishk:~/chef-repo/.chef$ nmap -p7 -Pn 172.31.4.235

Starting Nmap 6.40 ( http://nmap.org ) at 2015-08-25 15:25 IST
Nmap scan report for 172.31.4.235
Host is up.
PORT  STATE    SERVICE
7/tcp filtered echo

Nmap done: 1 IP address (1 host up) scanned in 2.24 seconds

But you won't be able ping as they should be in same subnet as in my case (my ip 172.19.24.36 )

ashish@ashishk:~/chef-repo/.chef$ ping  172.31.4.235
PING 172.31.4.235 (172.31.4.235) 56(84) bytes of data.
^C
--- 172.31.4.235 ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 3023ms

This means both hosts are not in same subnet. Try "ifconfig"to know more details of your ip & network.

It's output will help you to find whether both hosts are in same subnet or not !

If they are in same network then the box you are pining might have ping disabled !

Solution 2

Start with connectivity from the CentOS box. Can you ping any other hosts on the network?

If not, then you need to figure out what's going on there. Is the IP address in the same subnet as the other hosts on the network? You don't give any information about what IP and subnet mask the various hosts are set up with, or what your network looks like, so any help will be very generic.

In general, for a first time basic network, you'll normally end up with all hosts in the 192.168.1.x range, a subnet mask of 255.255.255.0 and a default gateway of 192.168.1.1. With this setup, all hosts in that network must be in the 192.168.1.x range.

You say you got connectivity working, how did you check that?

Share:
22,930

Related videos on Youtube

Mertcan Doğan
Author by

Mertcan Doğan

Updated on September 18, 2022

Comments

  • Mertcan Doğan
    Mertcan Doğan almost 2 years

    I am doing this for the first time, so I may be missing something very basic. I installed Centos 7 on a new server and have successfully gotten the connectivity working. Now I want to be able to ssh into the host.

    First, I need to find the ip address. I believe the correct way do this on Centos 7 is with the command ip addr show and using the address listen under inet for the nic I set up (this is correct right?)

    I am unable to ping this address. Using nmap -p7 -Pn $(addr), I see that there is a host at this address (I think it's mine!), but that this port (and port 22 for ssh) is being filtered:

    Host is up.
    PORT  STATE    SERVICE
    7/tcp filtered echo
    

    I thought that would mean the firewall is the problem. Just to check, I tried to turn off the firewall completely with systemctl stop firewalld and verified it was inactive with systemctl status firewalld. But I still can't ping the server and nmap continues to claim it's being filtered. So this either means that something else is doing the filtering or that I have the wrong ip address.

    What's the next thing to check?

    • Mertcan Doğan
      Mertcan Doğan almost 9 years
      tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 29815/sshd \n tcp6 0 0 :::22 :::* LISTEN 29815/sshd
    • serverliving.com
      serverliving.com almost 9 years
      SSH port seems to be 29815 & to know your correct public IP, you can execute this command from the server console "curl ifconfig.me" & then try doing remote SSH to that IP on 29815 port
    • Phil Sumner
      Phil Sumner almost 9 years
      No. 29815 is the PID. The "0.0.0.0:22" indicates it's listening on port 22.
    • serverliving.com
      serverliving.com almost 9 years
      Oh yes. I misread that, Are you getting a timeout on SSH connection?.
  • Mertcan Doğan
    Mertcan Doğan almost 9 years
    Somehow this host ended up on 192.168._0_ instead of .1 like my other machines. I think that is the problem. By getting connectivity working, I meant that I was able to get on the internet from the server.