Home Download Ubuntu

How to connect to the internet from Ubuntu 9.10 desktop using a router

First of all you need to configure correctly your router (dhcp, broadband, adsl, etc) before proceeding to this tutorial.
I would recommend using terminal to setup the internet connection.
If you have one network card in your Ubuntu computer, when you list available network cards by running:

ifconfig -a


you should see something like this:

eth0      Link encap:Ethernet  HWaddr 00:0e:e8:e6:4d:69
inet addr:192.168.0.2 Bcast:192.168.0.254 Mask:255.255.252.0
inet6 addr: fe80::20e:e8ff:fee6:4d69/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3933726 errors:0 dropped:0 overruns:0 frame:0
TX packets:7177941 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:500046836 (5.0 MB) TX bytes:1680685163 (1.6 MB)
Interrupt:19 Base address:0xef00

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 B) TX bytes:480 (480.0 B)


In this case your network card is eth0.

Now you need to edit /etc/network/interfaces file to manually configure your network card:

sudo nano /etc/network/interfaces


The new file will look something like this:

auto lo
iface lo inet loopback
auto eth0

iface eth0 inet static
address 192.168.2.100
netmask 255.255.255.0
gateway 192.168.2.1


Explication:

The code auto lo iface lo inet loopback auto eth0 is your loopback adapter. You don't need to care about it.
Next iface eth0 inet static tells that this network card will use a static ip adress.
address 192.168.2.100 will be your ip adress on local network which will need to be in the same class as router's (your router will need to have 192.168.2.1). Usually, router's ip adress is 192.168.1.1 or 192.168.0.1 or 192.168.2.1.
netmask 255.255.255.0 leave it like this.
gateway 192.168.2.1 is the gateway through which your computer is exiting to the internet and is the same as your router ip adress.

Now you'll need to configure dns's:

sudo nano /etc/resolv.conf


If you don't have nameserver on this file, you should prepend to it (don't delete the lines that are already there), and if you have nameserver you should edit it.

nameserver 192.168.2.1

which is your router's ip adress.

or

nameserver 208.67.222.222
nameserver 208.67.220.220

which are opendns dns's servers. They are usually faster the you provider's.

Now we restart network:

sudo /etc/init.d/networking restart

0 comments:

Post a Comment