Total visit on this blog

Monday 30 July 2012

How To Masquerade On Linux (Internet Connection Sharing)

IP Masquerade is a networking function in Linux similar to the one-to-many (1:Many) NAT (Network Address Translation) servers found in many commercial firewalls and network routers. For example, if a Linux host is connected to the Internet via PPP, Ethernet, etc., the IP Masquerade feature allows other “internal” computers connected to this Linux box (via PPP, Ethernet, etc.) to also reach the Internet as well. Linux IP Masquerading allows for this functionality even though these internal machines don’t have an officially assigned IP address.
MASQ allows a set of machines to invisibly access the Internet via the MASQ gateway. To other machines on the Internet, the outgoing traffic will appear to be from the IP MASQ Linux server itself. In addition to the added functionality, IP Masquerade provides the foundation to create a HEAVILY secured networking environment. With a well built firewall, breaking the security of a well configured masquerading system and internal LAN should be considerably difficult to accomplish.
Follow the following steps for performing masquerade:

Pre-Requirement

Machine 1 which is connected to WLAN(or dial-up connection) and also connected to machine 2 via LAN cable.
Machine 2 which is connected to machine 1 Via Lan cable

Steps for Machine 1 (which is connected to internet using a wifi connection i.e wlan0 or dial-up connection)

1. Open System -> Administration -> Firewall, and under ‘Masquerading’ select wlan0 (scroll down, if it’s not there add it), then click ‘Apply’
2. Set eth0 to ip 192.168.1.2, either via Network Manager or from the command line with
Code:
ifconfig eth0 192.168.1.2/24
(Assuming your wifi connection is in 192.168.1.* range)

Machine 2  (Connected to Machine 1 via ethernet cable from eth0)

1. Stop NetworkManager service since it’s easier without:
Code:
service NetworkManager stop
2. Set eth0 ip address to  and default gateway to 192.168.0.2:
Code:
ifconfig eth0 192.168.0.2
route add default gw 192.168.1.2
Check you can ping 192.168.1.2.
3. Now just set a DNS address in /etc/resolv.conf
Code:
nameserver 8.8.8.8
or
nameserver in the resolve.conf of Machine 1
now check. you can ping google.com.

Now enjoy the internet sharing. :) 

No comments:

Post a Comment