Saturday, July 30, 2011

Sharing internet connection(3g or ethernet) over Wifi on Fedora

Here are the steps, that I used to share my Reliance Netconnect connection over the wifi, so that I can use it on my android phone.

Fist of all, connect to Reliance Netconnect on your linux system. You can use wvdial or network Manager for that. You can see this connection on ppp0 interface(could be different from system to system).

Reliance Connection:      ppp0
Wifi ad-hoc connection:  eth1

*interface name(eth1/ppp0) could be different from system to system. So please change it accordingly

Prepare WIFI interface(eth1):

# ifconfig eth1 up

Change the wifi on Ad-hoc mode
# iwconfig eth1 mode Ad-Hoc

Set the essid for shared network
# iwconfig eth1 essid hotspot

Set the key for the ad-hoc wifi
# iwconfig eth1 key 123456789

Set ip address to this interface
# ifconfig eth1 up netmask

Set IP forwarding at kernel level:

# vim /etc/sysctl.conf
change entry "net.ipv4.ip_forward=0" to "net.ipv4.ip_forward=1"
# sysctl -p

Adding NAT ip rule in iptables:

# service iptables start
# iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
# service iptables save
# service iptables restart
# chkconfig iptables on

That is it. Your Linux system is sharing ppp0 internet connection over the wifi eth1 using essid "hotspot".

Connecting your phone with wifi:

1. Set the static IP configuration on your phone as follows:

    IP Address :
    Netmask    :
    Gateway    :
    DNS           : if you are using dnsmasq or local dns on linux system else use your pppo  connection dns )

Note: skip the above part if you are using dhcp on the linux system.

2. Scan for the ad-hoc wifi network with essid "hotspot" and connect to it.

Now you can start surfing on your phone. :)


1. Your Android phone need to be rooted for connecting to Ad-hoc Network.

2. You can share your ethernet Lan connection over wifi using this method. Just need to replace ppp0 interface with eth0.

3. You can add the wifi preparation steps to a script file. You can use this script to start this next time.

No comments: