Meniu

How to Setup a Home Network Using Static Addresses

If you have more than one computer at home, you’ll probably want to set up a network so that they can communicate. This way you’ll be able to share your Internet connection and to transfer files and services between your different computers. Most home networks have two functions: They connect the computers together on the same network and they connect that network to the Internet. The most popular technology to set up home network is called Ethernet and it uses a communication protocol called IP (which stands for “Internet Protocol”). All modern computers now have ethernet or wifi cards and it has become very easy to connect them to the network.

Connectivity

You’ll need some way of connecting your computers together. If you only have two computers and you’re not connected to the Internet, you can simply plug an ethernet crossed cable between them and that’ll do the trick. If you’re using Wifi, you can set up your computers to use ad-hoc and they’ll be “connected” through the air. However in most cases, you’ll want to connect them to a network with 2 or more computers and have the Internet shared on that network. For this, you’ll need a router.

Most routers now support both cable and wifi connections and they also have the ability to share an Internet connection on the network. The best router on the market for personal use is the Linksys WRT54G. Of course if you already have a router, there’s no reason to buy a new one. Plug your computers on the router with straight ethernet cables, plug your Internet connection cable in the router, and make sure both your router and your wifi enabled computers agree on a same name for the wifi network (This is called “essid”).

The Theory
IP Addresses and Netmasks

In order to communicate, computers must be on the same network and be assigned different IP addresses. A typical IP address looks like this 192.168.1.34 and is composed of a series a 4 numbers separated by dots. An IP address contains two pieces of information:
- The network’s identification
- The computer’s identification on that network

The netmask defines which part of the IP address identifies the network, and which part identifies the computer. A typical netmask looks like this: 255.255.255.0. To understand exactly how the netmask works we would have to translate it into binary and do some binary calculations… it’s a bit complex and we’ll look at that in a different article when we’ll address subnetting. For the moment, simply consider that 255 means “network” and 0 means “computer”. A netmask of 255.255.255.0 means that the first three 3 numbers of the IP addresses identify the network and the last one identifies the computer.

In our example we used the IP address 192.168.1.34 with a netmask of 255.255.255.0. This basically means that our computer is number 34 on the network 192.168.1.xxx. If our netmask was 255.255.0.0 then, our computer would be 1.34 on the network 192.168.xxx.xxx.

Remember that two computers can only communicate if they are placed on the same network. For instance, if computer A’s IP address is 192.168.0.23 and computer B’s IP address is 192.168.1.34. With a netmask of 255.255.0.0 they can communicate because they are both on the same network: 192.168.xxx.xxx. However, if their netmask is 255.255.255.0, then they won’t see each other, since A is on network 192.168.0.xxx and B is on network 192.168.1.xxx.

The most common values for netmasks are:
- 255.0.0.0. The networks which use this netmask are called “Class A Networks”.
- 255.255.0.0. The networks which use this netmask are called “Class B Networks”, typically used by ISPs.
- 255.255.255.0 The networks which use this netmask are called “Class C Networks”, typically used by small companies or home networks.

The numbers in a IP address usually range from 1 to 254, so you can basically have 254 computers on a Class C network. For instance, with a netmask of 255.255.255.0 (Class C) and a network address of 192.168.1.xxx you can assign IP addresses from 192.168.1.1 to 192.168.1.254.

In this article we’ll use a Class C network. It should be enough for you unless you have more than 254 computers at home (which is highly unlikely… right?). Our netmask will therefore be 255.255.255.0 and we’ll choose 192.168.1.xxx as our network address.

Routers and Gateways

The basic purpose of a router is to connect networks together. Your Internet access can be considered as an external network which your home network connects to via the router. If this is the case, your router acts a central piece of communication between your computers on the home network but also between your computers and the Internet. Each computer is then connected both to the network and indirectly to the Internet through the router. This means that any request sent by a computer will have to go through the router before going to another computer or to the Internet. As far as the computers are aware, the router acts as a gateway… a default destination to which all requests are sent to be routed to different places.

In this example we’ll use 192.168.1.1 as the IP address for the router. This will therefore be the gateway address set on every computer in our network.

DNS

When you type “google.com” in your navigator, your computer asks a DNS Server (DNS stands for Domain Name Service) to resolve the domain name “google.com” and to return its IP address. The DNS server has a database of domain names and their corresponding IP addresses. If a DNS server doesn’t know about a domain name, it asks another DNS Server. Thanks to these DNS Servers you don’t have to know Google’s IP address by heart to connect to it, and you can simply type its domain name “google.com”. Of course your computer needs to know at least the IP address of one DNS server, so it can know where to ask when a domain name is typed.

In this article we’ll assume your DNS Server IP address is 212.27.32.177. Make sure you know your own DNS Server IP address. In most cases, you can get this information from your Internet Service Provider.

Our network

In this article we’ll consider a sample network made of a router, an Internet access, two laptops and a desktop. To make things things simpler we gave names to our computers and routers:
- The desktop computer is called “Sun” and is plugged to the router via an Ethernet cable.
- The two laptops are called “Pluto” and “Jupiter” and they are connected via Wifi to the essid “galaxy”.
- The router is plugged to “Sun” via an Ethernet cable. It is also plugged to the Internet access cable and it is connected via Wifi to the essid “galaxy”.

We use a “Class C” network with a netmask of 255.255.255.0. Our network address is 192.168.1.xxx and we assign the following IP addresses:

- The router: 192.168.1.1
- Sun: 192.168.1.2
- Jupiter: 192.168.1.3
- Pluto: 192.168.1.4

The schema below illustrates the configuration of the network we’re using in this article:

Let’s do it!
Setting Sun’s IP address

On Sun, we’re using the ethernet card to connect to the router. In most Linux distribution the ethernet card interface is called “eth0″. In order to change its IP address, as root, we type:

ifconfig eth0 192.168.1.2 up

We can then verify that eth0 is using 192.168.1.2 with a netmask of 255.255.255.0 by typing “ifconfig”:

ifconfig

Setting up the Router

By default routers usually come with a default IP address of 192.168.0.1 and a default netmask of 255.255.255.0. In our example we want the router to use 192.168.1.1 so we’ll have to change its IP address. First we’ll need to change our own IP address in order for us to be on the same network as the router… let’s say 192.168.0.2:

ifconfig eth0 192.168.0.2 up

Once this is done, we can connect to the router through its web interface (most routers provide a Web server to allow the user to configure them). Let’s enter http://192.168.0.1 in our web browser. If your ask a password, have a look at the documentation that came with your router. If you own a Linksys WRT54G, the default login is blank and the default password is “admin”. Once you’re in the router’s web interface, go through the configuration and change its IP address to 192.168.1.1. You can then change back your IP address to be on 192.168.1.xxx so you can see the router again:

ifconfig eth0 192.168.1.2 up

We can now connect to the router via the web browser by connecting to http://192.168.1.1. Go through the router’s configuration and set it up according to your needs. Make sure you’re using the right configuration for your Internet access (in most cases the router acts as a DHCP client on the ISP network. You can get the information from your ISP). Make sure your Wifi settings are fine and that your essid is set (in our case it’s “galaxy”). And choose “static” addressing for your home network.

Connecting the laptops via WIFI

In most Linux distributions, the wifi card interface is eth1. However, some distribution use other interfaces such as wlan0 or even ra0. To make sure, you can use the “iwconfig” command, which lists your wireless

interfaces:

iwconfig

For our WIFI connection to work, we need to specify its mode and its essid. There are two basic modes for WIFI networks: Ad-Hoc and Managed. In this article we’re using a router and our network is typically managed, our router acts as Wireless Access Point.To set up the mode we type:

iwconfig eth1 mode managed

We can then set up the essid by typing:

iwconfig eth1 essid galaxy

Finally, we check that everything is fine by typing:

iwconfig

We do this on both laptops.

Then, we simply need to assign them an IP address. On Jupiter we type:

ifconfig eth1 192.168.1.3 up

And on Pluto:

ifconfig eth1 192.168.1.4 up

Setting up the default gateway

On each computer (Pluto, Jupiter and Sun) we need to set the router as the default gateway. We want all our requests to go to the router, so we’re using 192.168.1.1 as our default gateway:

route add default gw 192.168.1.1

Once this is done on each computer, they should be able to see each other. We make them ping each other to make sure the network works well.

If a problem occurs, you can see the routing table for a computer by typing:

route

Setting up the DNS

On each computer we need to set up the address of the DNS Server : 212.27.32.177. For this we edit the file /etc/resolv.conf. The file should contain the following:

nameserver 212.27.32.177

To make sure this works, we can query the DNS server for a particular domain name, for instance:

nslookup google.com

Conclusion

That’s it. Your network should work fine now. Of course every network is different and things might not work as expected. If you encounter any problem, please use the forum to ask questions. Good luck.

Mirela

Zona de mobile
  • | 34 articole

Nici un comentariu inca. Fii primul!
  • powered by Verysign