LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Setting up "hosts" on a standalone desktop PC (https://www.linuxquestions.org/questions/linux-from-scratch-13/setting-up-hosts-on-a-standalone-desktop-pc-925492/)

dllobach 01-24-2012 12:49 PM

Setting up "hosts" on a standalone desktop PC
 
I've recently gotten through LFS 7.0 and all is fine until I get to the networking part (never been my strong suite.) I've been all over LQ (and other places) trying to get past the infamous "unknown host" problem: to no avail. I think I'm getting screwed up with the etc/hosts file. Here's what I've got:

/etc/hosts:
Code:

127.0.0.1        localhost
127.0.1.1        LFS2

# The following lines are desirable for IPv6 capable hosts
::1    ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

/etc/resolv.conf
Code:

# /etc/resolv.conf
nameserver 74.128.17.114
nameserver 74.128.19.102

/etc/nsswitch.conf
Code:

passwd: files
group: files
shadow: files
hosts: files dns
networks: files
protocols: files
services: files
ethers: files
rpc: files

/etc/sysconfig/ifconfig.eth0
Code:

ONBOOT=yes
IFACE=eth0
SERVICE=ipv4-static
IP=74.138.128.1
#GATEWAY=74.138.128.1
PREFIX=24
BROADCAST=74.138.135.255

I've confirmed the info from a working Ubuntu on the same PC. The Ubuntu connections shows:
Code:

Interface:          Ethernet (eth0)
Hardware Address:    E0:CB:4E:C4:0E:48
Driver:              forcedeth
Speed:              100 Mb/s
Security:            None

IPv4
IP Address:          74.138.129.126
Broadcast Address:  74.138.135.255
Subnet Mask:        255.255.248.0
Default Route:      74.138.128.1
Primary DNS:        74.128.17.114
Secondary DNS:      74.128.19.102

and when I issue route -n command from Ubuntu it shows Gateway = 74.138.128.1

issuing hostname --all-fqdns shows 74-138-129-126.dhcp.insightbb.com

I think I'm screwing up the LFS /etc/hosts file but have tried so many variations I'm going in circles. Can anyone see where I'm going wrong?

Thanks in advance, DaleL

malekmustaq 01-24-2012 01:44 PM

Quote:

127.0.0.1 localhost
127.0.1.1 LFS2

Have you tried changing it to 127.0.0.1 just the same as localhost 127.0.0.1 ?

dllobach 01-24-2012 02:04 PM

Thanks for the quick reply!

I gave your thought a quick try on my LFS running on virtualbox but still get "unknown host" when I ping. I don't think it'll make a difference but I will try it again when I reboot into the dedicated LFS partition.

DaleL

Bertical 01-24-2012 05:09 PM

My network theory is a bit rusty ... aren't you on a /21 network with those numbers ?

dllobach 01-24-2012 08:06 PM

First, although i've come up with a word-around, I value your thoughts and would love further input in figuring this out.

Bertical, I'm not sure what "/21 network" is. As I've said, networking is a weak spot for me and even more so with Linux.

Soooooo, to make sure the problem wasn't with something I may have done while configuring the kernel, I did the following:

Copied the LFS 7.0 partition to a new partition (so I could preserve the build as it stood at the completion of the LFS 7.0 book.) Then I installed dhcp (dhcpcd-5.2.12) as per BLFS. Rebooted to the new partition (with dhcp) and things seem happy. Tried some pings against google and all was fine.

So, again begging your patience, I would love to figure out what I have messed up with the original LFS7 (without dhcp.)

Thanks,
DaleL

Bertical 01-25-2012 03:20 AM

The "PREFIX" command in /etc/sysconfig/ifconfig.eth0 is used to set the subnet mask. Your Ubuntu box is using 255.255.248.0 which is a /21 subnet mask ( first 21 bits are used for the network , the rest are used for the hosts ). On your LFS machine the subnet mask is set to /24.

dllobach 01-25-2012 11:52 AM

Bertical, thanks for the thought. I'm certainly not arguing with you, just going by the book which states that the IP address is four octets of 8 bytes (bits ?) each. So if the last octet is 0 then the first three are used and the prefix would be 24. I did try changing the prefix to 21 anyway but no go.

Thanks,
DaleL

Andrew Benton 02-06-2012 05:19 AM

Quote:

Originally Posted by dllobach (Post 4583387)
I gave your thought a quick try on my LFS running on virtualbox but still get "unknown host" when I ping.

Don't you need to create some sort of bridged connection when running in a virtual machine? At the bottom this page it talks about forwarding packets from the host.

dllobach 02-06-2012 01:57 PM

Andy, you may be right about virtualbox but I have also tried booting straight into LFS on its own partition and have tried every combination I can imagine. No luck. Bertical may also be onto something with the subnet mask but simply changing the PREFIX in my ifconfig didn't work. I've spent quite a few hours with google trying to learn more about the networking part and am still learning. I'm beginning to think that since it works fine with DHCP maybe it can't be done by putting addresses in myself. (LFS on virtualbox also works fine if I use DHCP.) I've been going through the scripts run by INIT but can't get the specific error from those scripts. I think that one day when I feel adventurous I'm going to have to but some debugging in the "ping" program and see exactly what is being returned when it fails. Thanks for your thoughts.

Bertical 02-09-2012 10:11 AM

Your network is 74.138.128.0 with a 255.255.248.0 subnet mask. This gives a range of host IP addresses from 74.138.128.1 to 74.138.135.254.

74.138.128.1 has been already allocated to your gateway ( according to the Ubuntu details )

74.138.135.255 is the broadcast address for your network and can't be used.

You need to assign an IP address from the range 74.138.128.2 to 74.138.135.254.

You need to change the PREFIX to 21 so your PC is in the correct subnet ( it can only see 74.138.128.0 - 74.138.128.255 at the moment )

You also need to uncomment the GATEWAY directive in eth0 config file so your PC can get to other networks via the gateway.


I think .... :scratch: :D

dllobach 02-10-2012 12:31 AM

Bertical, thanks much for the info. While I don't have it fixed just yet, I am beginning to think LFS is working fine and I should perhaps learn more over in the networking forum.

Just one last question if I may: is it possible that connecting to my ISP through a modem (no router) mandates that I have dhcp of some kind running on my PC?

Meanwhile I did change the IP Address to the exact same one Ubuntu uses (note that I am booting directly into LFS, not virtualbox now.) I also changed the PREFIX to 21 and enabled the gateway. Now, at the end of init, I am getting a message that the default gateway is set up. Ping still gives me "unknown host" when pinging www.google.com but now tells me that the destination host is unreachable when I ping 8.8.8.8. From what I've found on google, I still have a "route" problem.

Since I would really like to learn just what is going on I think I'm going to dig out a live CD for another distribution (or perhaps the LFS liveCD) and watch the discovery process. I have Ubuntu and Mint but Ubuntu seems to use avahi and Mint is a derivative of Ubuntu so probably uses avahi also. I'd like to dig into the network part of INIT on liveCD to see just how it is acquiring addresses. A liveCD would surely have a dhcp type discovery process. Again, if my ignorance is showing and this all is a simple matter of DHCP being needed to connect to my ISP, don't be afraid to call me an idiot.

Thanks again for your help.


All times are GMT -5. The time now is 11:32 PM.