Connecting to internet is an important task for every user. This guide explains you how to connect internet in ubuntu linux. There are two ways to connect internet in ubuntu, one is wired connection and another is wireless connection. Also add name server entries in resolv.conf

Open Terminal and edit /etc/resolv.conf

vim /etc/resolv.conf
nameserver 8.8.8.8  # Primary nameserver

nameserver 8.8.4.4 # Secondary nameserver

Setup Wired Connection

If you are using dial-up connection, follow this documentation : How to connect internet using PPPOE

The other way is connecting to internet via DHCP Server, It provides both dynamic and static ip address to client boxes.

Assign Dynamic IP Address

If you are willing to use DHCP dynamic ip address, set your /etc/network/interfaces entries as shown below

vim /etc/network/interfaces
# Loopback IP Address

auto lo
iface lo inet loopback

# DHCP Wired Connection : eth0 device

auto eth0
iface eth0 inet dhcp

Assign Static IP Address

If you are having static ip then setup your /etc/network/interfaces entries as shown below

# Loopback IP Address

auto lo
iface lo inet loopback

# DHCP Wired Connection : eth0 device

auto eth0
iface eth0 inet static
address 192.168.1.123
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.73

Setup Wireless Connection

If you are having wireless connection and you are using DHCP Server for assigning ip address then follow the below procedure

Assign Dynamic IP Address 

If you are willing to use dynamic address, setup the /etc/network/interfaces entry as shown below.

vim /etc/network/interfaces
# Loopback IP Address

auto lo
iface lo inet loopback

# DHCP Wireless Connection : wlan0 device

auto wlan0
iface wlan0 inet dhcp

Assign Static IP Address

If you would like to use static ip address then setup your /etc/network/interfaces as shown below

vim /etc/network/interfaces
# Loopback IP Address

auto lo
iface lo inet loopback

# DHCP Wired Connection : wlan0 device

auto wlan0
iface wlan0 inet static
address 192.168.1.125
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.73

After configuring it please restart the network services

/etc/init.d/networking restart

or

service networking restart

Gateway

Check the gateway, if you don’t have gateway information in route entry add gateway information in it.

route -n

or

netstat -rn

If you want to delete the default gateway

route del default gw

If you want to add a default gateway

route add default gw

Connecting internet with Modem

If you are having wireless modem ( for example : Reliance Netconnect + ) then you need to install some wireless tools before to configure it.

WV-dial is an utility, point to point protocol dialer which allows your modem to connect with internet.

Usually the wvdial configuration file is located under /etc/wvdial.conf which contains basic information about the modem port, speed, and init string, along with information about your Internet Service Provider (ISP), such as the phone number, your username, and your password.

Run wvconf in your terminal, it will create a configuration file. After running wvdial it will probe your common ports, looking for a modem, and determine the capabilities of any modems.

sudo wvdialconf
Scanning your serial ports for a modem.

ttyS1<*1>: ATQ0 V1 E1 — OK
ttyS1<*1>: ATQ0 V1 E1 Z — OK
ttyS1<*1>: ATQ0 V1 E1 S0=0 — OK
ttyS1<*1>: ATQ0 V1 E1 S0=0 &C1 — OK
ttyS1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 — OK
ttyS1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 — OK
ttyS1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 +FCLASS=0 — OK
ttyS1<*1>: Modem Identifier: ATI — 28800
ttyS1<*1>: Speed 2400: AT — OK
ttyS1<*1>: Speed 4800: AT — OK
ttyS1<*1>: Speed 9600: AT — OK
ttyS1<*1>: Speed 19200: AT — OK
ttyS1<*1>: Speed 38400: AT — OK
ttyS1<*1>: Speed 57600: AT — OK
ttyS1<*1>: Speed 115200: AT — OK
ttyS1<*1>: Max speed is 115200; that should be safe.
ttyS1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 S11=55 +FCLASS=0 — OK
ttyS0<*1>: ATQ0 V1 E1 — ATQ0 V1 E1 — ATQ0 V1 E1 — nothing.
Port Scan<*1>: S2 S3

Found a modem on /dev/ttyS1.

If you didnt get output as shown above, please check your modem connectivity.

This is the sample wvdial.conf file

[Dialer Defaults]
Modem = /dev/ttyS1
Baud = 57600
Init = ATZ
Init2 = AT S11=50
Phone = your phone number
Username = your username
Password = your password

Save and quit the file

For more about WVdial check this ubuntu documentation

Now activate your connection by using the following command

sudo ifconfig eth0 up

For more check this documentation : Activating and deactivating Network Interface Cards

To check your assigned ip address information use ifconfig command.

ifconfig

If you have any problems to connect internet, please let me know through comments.

Related articles


Subscribe Our Free Newsletter

Delivered by FeedBurner. We Respect Your Privacy

Tagged with:
 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>