LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-11-2018, 05:39 PM   #1
cuteclown
LQ Newbie
 
Registered: Jul 2018
Distribution: Arch Linux
Posts: 5

Rep: Reputation: Disabled
[Solved] Unknown host/unreachable network after following LFS


I have followed Linux From Scratch 8.2. I have a laptop with an ethernet port with a plugged-in ethernet cable that I'm trying to use to ping google and get a response. I have a network interface with the name enp0s25, and my default gateway address is 192.168.178. I am trying to use the IP address 192.168.1.2 (there is no specific reason I'm using this IP address - can I just pick one?).

During boot I get the message:
Setting up default gateway...RTNETLINK answers: Network unreachable

Now, ping doesn't work:
Code:
> ping -c 4 google.com
ping: unknown host
> ping 192.168.178.1
ping: sending packet: Network is unreachable
Although I can ping the default gateway after adding it:
Code:
> ip addr add 192.168.178.1 dev enp0s25
> ping -c 1 192.168.178.1
PING 192.168.178.1 (192.168.178.1): 56 data bytes
64 bytes from 192.168.178.1: icmp_seq=0 ttl=64 time=0.045 ms
--- 192.168.178.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.045/0.045/0.045/0.000 ms
> ping google.com
ping: unknown host
I am probably doing something wrong. In particular, I don't know if the IP address I'm picking is okay or not. Help is greatly appreciated.

/etc/sysconfig/ifconfig.enp0s25
Code:
ONBOOT=yes
IFACE=enp0s25
SERVICE=ipv4-static
IP=192.168.1.2
GATEWAY=192.168.178.1
PREFIX=24
BROADCAST=192.168.1.255
/etc/resolve.conf
Code:
nameserver 8.8.8.8
nameserver 8.8.4.4
/etc/hostname
Code:
lfs
/etc/hosts
Code:
127.0.0.1 localhost
192.168.1.2 lgs.mydomain.org lfs

Last edited by cuteclown; 07-12-2018 at 02:12 AM. Reason: Problem solved
 
Old 07-11-2018, 08:02 PM   #2
flshope
Member
 
Registered: Jul 2009
Location: Murfreesboro TN (United States)
Distribution: Ubuntu 16.04.4 and 14.04.5, Debian 9.4
Posts: 145
Blog Entries: 37

Rep: Reputation: 29
Make sure the site you are pinging is actually returning pings

I can't help much with configuring networking, but I have discovered that not all web sites (URLs) return pings. For example, when I do a 'ping www.debian.org", I never get a return ping. But when I do a 'ping www.ubuntu.com', I always get the return ping if my network is up.

When I tried your 'ping -c 4 google.com', I did not get a return ping from google (schmucks!). I just get the 'Address unreachable' messages. Perhaps it is site policy to return or not return pings.

So I have found it important to make sure the site I am pinging is actually returning pings. That takes another computer that you know has an active network connection.
 
1 members found this post helpful.
Old 07-11-2018, 08:47 PM   #3
mralk3
Senior Member
 
Registered: May 2015
Distribution: Slackware, Debian, CentOS, FreeBSD
Posts: 1,116

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
Quote:
Originally Posted by cuteclown View Post
I have followed Linux From Scratch 8.2. I have a laptop with an ethernet port with a plugged-in ethernet cable that I'm trying to use to ping google and get a response. I have a network interface with the name enp0s25, and my default gateway address is 192.168.178. I am trying to use the IP address 192.168.1.2 (there is no specific reason I'm using this IP address - can I just pick one?).

During boot I get the message:
Setting up default gateway...RTNETLINK answers: Network unreachable

Now, ping doesn't work:
Code:
> ping -c 4 google.com
ping: unknown host
> ping 192.168.178.1
ping: sending packet: Network is unreachable
Although I can ping the default gateway after adding it:
Code:
> ip addr add 192.168.178.1 dev enp0s25
> ping -c 1 192.168.178.1
PING 192.168.178.1 (192.168.178.1): 56 data bytes
64 bytes from 192.168.178.1: icmp_seq=0 ttl=64 time=0.045 ms
--- 192.168.178.1 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.045/0.045/0.045/0.000 ms
> ping google.com
ping: unknown host
I am probably doing something wrong. In particular, I don't know if the IP address I'm picking is okay or not. Help is greatly appreciated.

/etc/sysconfig/ifconfig.enp0s25
Code:
ONBOOT=yes
IFACE=enp0s25
SERVICE=ipv4-static
IP=192.168.1.2
GATEWAY=192.168.178.1
PREFIX=24
BROADCAST=192.168.1.255
/etc/resolve.conf
Code:
nameserver 8.8.8.8
nameserver 8.8.4.4
/etc/hostname
Code:
lfs
/etc/hosts
Code:
127.0.0.1 localhost
192.168.1.2 lgs.mydomain.org lfs
You are setting you ip address to 192.168.1.2, but your gateway is on the subnet 192.168.178.0/24. Assuming your gateway and network are on that subnet, and are not using DHCP protocol to assign ip addresses, set your static ip address on your linux from scratch machine to 192.168.178.2 and broadcast address to 192.18.178.255. Restart your network service and you should have an active connection.
 
2 members found this post helpful.
Old 07-12-2018, 02:11 AM   #4
cuteclown
LQ Newbie
 
Registered: Jul 2018
Distribution: Arch Linux
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by mralk3 View Post
You are setting you ip address to 192.168.1.2, but your gateway is on the subnet 192.168.178.0/24. Assuming your gateway and network are on that subnet, and are not using DHCP protocol to assign ip addresses, set your static ip address on your linux from scratch machine to 192.168.178.2 and broadcast address to 192.18.178.255. Restart your network service and you should have an active connection.
That makes sense. I changed the line containing my IP in /etc/resolv.conf to
Code:
IP=192.168.178.2
so that the first three bytes (the 24-bit prefix) match the IP of my default gateway.

I knew it had to be something stupid like this... Thank you very much!

Last edited by cuteclown; 07-12-2018 at 02:14 AM.
 
Old 07-12-2018, 12:13 PM   #5
mralk3
Senior Member
 
Registered: May 2015
Distribution: Slackware, Debian, CentOS, FreeBSD
Posts: 1,116

Rep: Reputation: 469Reputation: 469Reputation: 469Reputation: 469Reputation: 469
Quote:
Originally Posted by cuteclown View Post
I knew it had to be something stupid like this... Thank you very much!
Not stupid! It's all a learning experience with LFS. Glad I could help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] LFS 7.9 Networking Issues, Ping: Unknown Host/Destination Unreachable cxd Linux From Scratch 3 07-30-2016 03:33 PM
iptables - Reply Forwarding Error / Destination unreachable (Host unreachable) keflex87 Linux - Networking 1 05-12-2015 12:03 AM
Network is Unreachable/Unknown host/Destination Host Unreachable [Debian] denv Linux - Networking 4 03-27-2014 02:58 PM
Linux network destination host unreachable linuxguy08 Linux - Server 1 07-22-2009 06:23 PM
wlan0 network & host unreachable soupy Linux - Networking 5 10-30-2005 05:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration