MandrakeUser.Org - Your Mandrake-Linux Knowledge Base!


 
 

* DocIndex - Connectivity

Building A Small Mixed Network II (Practice)

* Writing A hosts File
* MS Windows
* Linux
* Mac OS X
* Conclusion

Related Resources:

man hosts
MS Windows 98 Networking
Windows XP Network Protocols
man lookupd (OS X)
Troubleshooting TCP/IP Networks

Revision / Modified: May 23, 2002
Author: Tom Berger

 

* Writing A hosts File

In order to reach each of the machines on a network by a name rather than by the IP number of its network interface, you have to write a 'hosts' file.

The example network consists of four machines, each with a different operating system:

  1. The machine running Mandrake Linux 8.2 will be configured to get the IP number 10.0.0.10. Its full name will be 'terra.sol.lan', its short names 'terra' and 'linux'.
  2. The machine running MS Windows 98 will be configured to get the IP number 10.0.0.11. Its full name will be 'pluto.sol.lan', its short names 'pluto' and 'win98'.
  3. The machine running MS Windows XP will be configured to get the IP number 10.0.0.12. Its full name will be 'terra.sol.lan', its short names 'saturn' and 'winxp'.
  4. The machine running Mac OS X 10.1.4 will be configured to get the IP number 10.0.0.13. Its full name will be 'venus.sol.lan', its short names 'venus' and 'macx'.

For this setup, you would write a 'hosts' file like this:

# hosts file
127.0.0.1 localhost.localdomain localhost
10.0.0.10 terra.sol.lan terra linux
10.0.0.11 pluto.sol.lan pluto win98
10.0.0.12 saturn.sol.lan saturn winxp
10.0.0.13 venus.sol.lan venus macx

The first entry denotes the standard local loopback interface.
If there's a router on the network, it will get the IP 10.0.0.1 in this example.
I assume that your router does DNS forwarding / caching (most do). If it doesn't, you will have to use your provider's DNS addresses instead of the IP number of your router when configuring DNS on the clients.

Save this file under the name 'hosts' and put it on a removable medium. The name of the file must be 'hosts', not 'hosts.txt' or 'Hosts' or similar. Keep in mind that every IP number and name on the network must be unique.

* section index * top

* MS Windows

Windows 98

  1. Copy the 'hosts' file to the 'c:\windows' directory.

  2. Go to 'control panel - network'. An entry for your network card should already appear in there (if not, install the driver for the card). Look if you see an entry for a protocol that points to that card. Unless this protocol is TCP/IP, remove it.
    Mark the entry of the card, click 'Add', choose 'Protocol - Microsoft - TCP/IP'. Approve. Now you should have an entry in the network panel like 'TCP/IP -> [your network card]' (or vice versa).

  3. Highlight this entry, click 'Properties'. Set the IP for this machine (10.0.0.11) and the subnet mask (255.255.255.0).

  4. If you are going to use a router, set its IP (10.0.0.1) in the 'Gateway' tab.

  5. If you are going to use a router, click on the 'DNS configuration' tab and check 'Enable DNS'. Enter 'pluto' into the 'host' field and 'sol.lan' into the 'domain' field. Enter the IP of your router (10.0.0.1) into the 'DNS Server' field.

  6. Close the network dialog and follow the system instructions.

  7. After rebooting the system, open a DOS window and type

    ping 10.0.0.11

    You should get something like:

    Pinging 10.0.0.11 with 32 bytes of data:

    Reply from 10.0.0.11: Bytes=32 time<10ms TTL=128
    (repeated three times)

  8. Run

    ping pluto

    You should get:

    Pinging pluto.sol.lan [10.0.0.11] with 32 bytes of data:

    Reply from 10.0.0.11: Bytes=32 time<10ms TTL=128
    (repeated three times)

Congratulations, you just configured your first machine! Three more to go.

Windows XP

Windows XP stores the 'hosts' file in the 'windows\system32\drivers\etc\' directory. You can safely overwrite the existing 'hosts' file in that directory (it just contains the local loopback interface).

  1. Click 'Start' > 'Control Panel'. Click 'Network and Internet Connections'. Click 'Network Connections'. Double-click 'Local Area Connection'. Click 'Properties' (I love this).
    If Internet Protocol (TCP/IP) is not already installed, click 'Install', double-click 'Protocol', highlight 'Microsoft' in the left window, and 'Internet Protocol (TCP/IP)' in the right window. Click 'OK'.

  2. Click 'Internet Protocol (TCP/IP)' and then click 'Properties'. Check 'Use the following IP address'. Enter '10.0.0.12' in the 'IP Address' field, hit TAB key to auto-complete the 'Subnet mask' field.
    If you are using a router, enter its IP number (10.0.0.1 in our example) into the 'Default gateway' and 'Preferred DNS server' field. Click 'OK'.

  3. Open a terminal window and do the same tests as above with the IP and the name of the current machine ('10.0.0.12' and 'saturn') as well as with the IP and the name of the machine you've already configured. If both works, you've already got a working local area network!

* section index * top

* Linux

Copy the 'hosts' file to the '/etc' directory as 'root'.

  1. Open the Mandrake Control Center. Click 'Network & Internet', click 'Connection', click 'Wizard...', click 'Next'.

  2. Check if 'LAN connection' is marked. Click 'Next', click 'OK'.

  3. Enter IP address (10.0.0.10 in our example) and netmask (255.255.255.0). Click 'Next'.

  4. Enter the hostname (terra.sol.lan). If you are using a router, enter its IP (10.0.0.1) in the 'DNS address' and the 'Gateway' field. If you are not using a router, enter your ISPs DNS address in the DNS address field. Unlike MS Windows, Linux does not accept dynamically assigned DNS addresses. If you enter no DNS address here, you might run into routing trouble later.

  5. Click 'Next' and confirm.

  6. Run the same checks as for the previous machines. If the shell can't find the 'ping' command, install the 'iputils' package. If it doesn't work, check '/etc/resolv.conf' and '/etc/sysconfig/network' for correct values.

* section index * top

* Mac OS X

Copy the contents of your 'hosts' into the '/etc/hosts' file of Mac OS X.

  1. Set the hostname by editing '/etc/hostconfig' and setting HOSTNAME to 'venus.sol.lan':

    HOSTNAME=venus.sol.lan

  2. By default, Mac OS X does not use the '/etc/hosts' file for name resolution in all other runlevels than 1 (single user). To change this, you have to change the lookup order of 'lookupd':

    1. Create a directory /etc/lookupd, e.g. with sudo mkdir /etc/lookupd

    2. Create a new file in that directory called 'hosts' (e.g. with pico -w /etc/lookupd/hosts) and put this line in there:

      LookupOrder FFAgent DNSAgent NIAgent

    3. Restart 'lookupd' with

      sudo kill -USR1 $(cat /var/run/lookup.pid)

  3. Perform tests as above.

* section index * top

* Conclusion

If you can 'ping' each machine on your network, you are set. You can now go on and configure such services as Sambaor NFS.

If you run into trouble along the way or afterward, read this article again, especially the page on theory, which should cover (almost) all potential pitfalls.
If you can't figure it out on your own and ask others for help, you can speed up things immensely by providing the output of the commands route -n, ifconfig and the content of the files '/etc/sysconfig/network' as well as '/etc/resolv.conf' along with your question. If your problem is related to MS Windows, provide the output of the Windows console command ipconfig /ALL.

Happy LANing! :-)

* section index * top


 
Legal: All texts on this site are covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.