LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Help with network configuration in Chapter 7.2.2 of LFS 7.1 (https://www.linuxquestions.org/questions/linux-from-scratch-13/help-with-network-configuration-in-chapter-7-2-2-of-lfs-7-1-a-4175444415/)

engineer 01-06-2013 08:09 PM

Help with network configuration in Chapter 7.2.2 of LFS 7.1
 
In chapter 7.2.2, the book requires us to create the network interface config files resolv.conf and ifconfig.

In these files, there are several parameters that are required that I'm not sure of how to find the correct information. Namely: gateway, IP (can I make this arbitrary 192.168.1.X based upon the other devices in my network?), Prefix, broadcast, and the DNS server IP I should use.

Can anyone point me in the right direction as to where I can find this information?

I am using a wireless connection (now called wlan0) on my laptop.

k84834 01-07-2013 12:29 AM

Quote:

can I make this arbitrary 192.168.1.X based upon the other devices in my network?
yes, when I was building my lfs, I use these info from my host machine. after your lfs will be booted, you can use from DHCP which is addressed in the BLFS book. you can set an static IP that is in your network IP range. other variables could be obtained from IP and GATEWAY.
in the resove.conf file, I think below info is enough:
nameserver 127.0.0.1
nameserver YOUR-GATEWAY_VALUE

Keith Hedger 01-07-2013 11:20 AM

If in doubt set nameserver to 8.8.8.8 which is the free google dns server and is usually quite fast and reliable ( more so than bloody awful BT )

gateway is usually the ip of your router.

stoat 01-07-2013 10:46 PM

Quote:

Originally Posted by engineer

Namely: gateway, IP (can I make this arbitrary 192.168.1.X based upon the other devices in my network?), Prefix, broadcast, and the DNS server IP I should use.

Hello everybody,

As already mentioned, try using the IP of your router as the gateway IP. You can change your router's IP if you think you need to. I have a Linksys router and a Motorola DSL modem that use the same default network IP address (192.168.1.XXX). When the modem is in PPPoE mode and the router is in DHCP mode, I have to change the router's network address to 192.168.2.XXX for that arrangement to work. None of this matters if the DSL modem is in bridged mode and the router is configured to handle the DSL connection. Anyway, that is an example of a reason to change the router's address and the ifconfig file stuff, too.

The prefix thing is another way of expressing the subnet mask which establishes the parts of an IP address that identify the network and which part is reserved to identify the hosts on the network. A common subnet mask (the default, really) is 255.255.255.0 which can be thought about in binary digits like this 11111111.11111111.11111111.00000000. Those twenty-four one bits act (via a logical AND comparison to IP addresses) to sort of reserve the first three octets of the IP for the network and are where the "24" comes from for the prefix number for that example. Subnet mask. Prefix. Same thing expressed differently, IMO. Anyway, that leaves the eight bits of the last IP address octet to identify hosts on the network (256 possible hosts minus some reserved for the router itself and broadcast purposes). You can use the setup utility of your router to see its subnet mask and the IP address used by the router. You can convert the router's subnet mask to a prefix for your ifconfig, but I imagine it will be the one in the example above.

My understanding of the broadcast IP is that it usually is the network octets plus 255 (but in some cases, 000) for the fourth octet (e.g., 192.168.1.255). A broadcast packet sent by the router (for various reasons) to the broadcast IP address will be accepted and processed by all hosts on the subnet.

But as already mentioned, another system (such as your LFS host system) is a good place to look for these and many other config file settings.

The DNS nameserver IP can be your router as already mentioned. That probably will work okay by the router getting DNS nameservers provided by your ISP. You also can specify those ISP nameserver IPs directly in your resolv.conf. Or, use Google's as mentioned. Many people use OpenDNS's nameservers. I like to use my ISP's DNS nameserver addresses in the resolv.conf.

Anyway, this is how I view the world.

engineer 01-08-2013 05:48 PM

Ok, per the responses above, I've used my previous config files (from the base system) to give me hints to create the new config files. I wound up using my default nameserver from my service provider (it was in the resolv.conf file on the base system), and added google's as a backup. I took the IP for my router as the default gateway. I used the last IP address in the range for the broadcast-192.168.1.255.

Final question: for the SERVICE flag, the instructions say to set this to static. I'm assuming that I have a dynamic IP provided by my ISP (how can I find out?), so after looking around, it looks like this can be set to 'dhcp'. Is this OK?

Thank you, and especially thanks to stoat for such a detailed post. rep'd.

stoat 01-08-2013 06:17 PM

The book specifies static IP addressing because no DHCP client has been installed yet. That's in the BLFS book. And then, it's about the private subnet IP address your network interface acquires from your router, not the one your modem acquires from your ISP. Try the ipv4-static thing as the SERVICE, and specify an IP in the range set in your router config for users. It probably has a starting IP address and a maximum number allowed. Anyway, that's what I do here at home. But my connection is wired and stays at home. You have a laptop and may end up needing a DHCP client someday to connect at Starbucks. And maybe wpa_supplicant to negotiate encrypted connections (also a BLFS topic).

P.S.: If you're wanting to use a wireless connection right now, there are other things you will need that are not in the LFS book such as wireless-tools, a wireless driver maybe, and kernel config stuff. There are LFS hints about wireless and WPA. They're a little old, but probably still provide the gist of it all.

engineer 01-08-2013 08:47 PM

OK, I changed the ifconfig.wlan0 file back to 'ipv4-static', so it now looks like this:

Code:

root:/sources/linux-3.2.6# cat /etc/sysconfig/ifconfig.wlan0
ONBOOT=yes
IFACE=wlan0
SERVICE=ipv4-static
IP=192.168.1.10
GATEWAY=192.168.0.1
PREFIX=24
BROADCAST=192.168.1.255

I'll wait until I boot into the system and check the connection before I mark the thread SOLVED :).

k84834 01-09-2013 02:18 AM

Quote:

Originally Posted by engineer (Post 4865823)
OK, I changed the ifconfig.wlan0 file back to 'ipv4-static', so it now looks like this:

Code:

root:/sources/linux-3.2.6# cat /etc/sysconfig/ifconfig.wlan0
ONBOOT=yes
IFACE=wlan0
SERVICE=ipv4-static
IP=192.168.1.10
GATEWAY=192.168.0.1
PREFIX=24
BROADCAST=192.168.1.255


I think your GATEWAY may be 192.168.1.254 when your IP is 192.168.1.10 and your BROADCAST is 192.168.1.255 and your PREFIX is 24.

stoat 01-09-2013 05:34 PM

I haven't needed a wireless connection with my BLFS systems yet, but I was planning to work my way through that in the near future anyway. So today I experimented with setting it up with a static IP and WPA encryption. It went pretty much okay. FWIW (maybe nothing), here is what happened... Installed wpa_supplicant and libnl (already have openssl and the others). Recompiled the kernel with all the usual wireless stuff and the built-in zd1211rw driver module needed by this ZyXel USB adapter I had lying around. Copied the firmware for the zd1211rw driver to /lib/firmware/zd1211. Created /etc/wpa_supplicant.conf using wpa_passphrase with the router's SSID and WPA password. Created /etc/sysconfig/ifconfig.wlan0 as already discussed here. Tweaked /etc/udev/rules.d/70-persistent-net.rules for wlan0. Fiddled with /etc/sysconfig/ifconfig.eth0 to stop eth0 from going up at boot time. Unplugged the wired NIC cable to prevent being tricked by eth0 (just in case). Rebooted, brought the interface up, and established a connection with the usual terminal commands (no connection manager for this experiment). It's all in the book and the hints and the things already mentioned above.

P.S.: I let the network init script bring up the wlan0 interface during booting (ONBOOT=yes). The init screen was normal, happy, and pretty during booting. And I put the wpa_supplicant command in $HOME/.bash_profile to establish the router connection sort of automatically. For a permanently attached wireless device, that scheme makes the whole thing come up and work in the background just like the ethernet connection does. For a hot-plugged wireless device, some other arrangement will be needed. I'm not interested though.

engineer 01-21-2013 08:11 PM

Update to mark the thread as SOLVED:

Code:

root:/sources/linux-3.2.6# cat /etc/sysconfig/ifconfig.eth0
ONBOOT=yes
IFACE=eth0
SERVICE=ipv4-static
IP=192.168.1.10
GATEWAY=192.168.0.1
PREFIX=24
BROADCAST=192.168.1.255

I had to change the IP address to 192.168.0.10 to make sure it is in the subnet I have given here. I haven't got the wlan0 working, but eth0 is now working.


All times are GMT -5. The time now is 03:40 PM.