sharing internet connection in ubuntu
TRANSCRIPT
8/3/2019 Sharing Internet Connection in Ubuntu
http://slidepdf.com/reader/full/sharing-internet-connection-in-ubuntu 1/3
Sharing Internet Connection in Ubuntu Setting up a computer to share its internet connection should be easy. After all, you’ve
successfully networked your computers together and even shared files with all your home
computers, so why not the Internet? Well if you have a small home network of computers allconnected and have tried to open up a browser, you’ve probably found out that things aren’t
quite as straight forward as connecting one machine with an Ethernet cable to the computer that
has the DSL/cable modem.
The secret is that everything comes down to having a gateway.
A gateway is a computer or device than can route data between different networks. Put it this
way, if your computers are on one network and every other computer connected to the Internet is
on a different one, to pass information across network boundaries you need a device which is
connected to both networks and equipped to decide whether information from one network
should go out to the other network, and vice versa.
The computer in your small network which is directly connected to the cable or DSL modem is
provided with a default gateway by the Internet service
provider or business dsl.
So, without a gateway there is no way for the other computers in your network to receive or pass
information to the other networks, and consequently, they have no Internet access.
The computer in your small network which is directly connected to the cable or DSL modem is
provided with a default gateway by the Internet service provider. That allows the computer to
connect to the interenet, but unfortunately for us that gateway is not part of your home network -rather it is a separate network formed between the computer connected to the cable/DSL modem
and the ISP itself.
In order to enable Internet access on the rest of your small home network, the computer or device
that connects with your ISP must become a gateway for the computers in your local home
network. Once this has been configured, it will enable all of the other home network computers
to access the Internet by sending and receiving information through that gateway.
The easiest way of acquiring a gateway for your home network is to buy a cable/DSL router.
Given how cheap they currently are (about a quarter of the price they commanded when they
first appeared in the marketplace), there really isn’t much of an excuse not to buy one.
The major advantages of having a hardware router doing your internet sharing include minimal
configuration, since they are set up to act as a gateway by default (it’s pretty much all they do),increased reliability (they are not a PC… PCs crash.), and security, since most of these devices
incorporate a firewall. Highly recommended!
You’ll also need
8/3/2019 Sharing Internet Connection in Ubuntu
http://slidepdf.com/reader/full/sharing-internet-connection-in-ubuntu 2/3
a working dial-up Internet account with an Internet Service Provider (ISP) or
a working broadband (cable, DSL, satellite, etc.) Internet connection.
Share your Internet connection using the following Procedure
Note: Type all the following commands in a root terminal
Start by configuring the network card that interfaces to the other computers on you network
# ifconfig ethX ip
where ethX is the network card and ip is your desired server ip address (Usually 192.168.0.1 is
used)
Then configure the NAT as follows
# iptables -t nat -A POSTROUTING -o ethX -j MASQUERADE
where ethX is the network card that the Internet is coming from
# echo 1 > /proc/sys/net/ipv4/ip_forward
Install dnsmasq and ipmasq using the following command
# apt-get install dnsmasq ipmasq
Restart dnsmasq using the following command
# /etc/init.d/dnsmasq restart
Reconfigure ipmasq to start after networking has been started
# dpkg-reconfigure ipmasq
Start by configuring the network card that interfaces to the other computers on you network
# ifconfig ethX ip
where ethX is the network card and ip is your desired server ip address (Usually 192.168.0.1 is
used)
Then configure the NAT as follows
# iptables -t nat -A POSTROUTING -o ethX -j MASQUERADE
8/3/2019 Sharing Internet Connection in Ubuntu
http://slidepdf.com/reader/full/sharing-internet-connection-in-ubuntu 3/3
where ethX is the network card that the Internet is coming from
# echo 1 > /proc/sys/net/ipv4/ip_forward
Add the line “net.ipv4.ip_forward = 1″ to /etc/sysctl.conf
# gedit /etc/sysctl.conf
Reboot your system is optional.