Sharing ppp connection with wlan interface
From ArchWiki
[edit] Requirements
The following programs must have been installed in order to share the ppp connection:
- Programs for configuring your wlan card (package wireless_tools)
- Programs for configuring generic network interface card (package net-tools)
- The iptables program which is used to manipulate how data is passed through your machine from your clients and back (package iptables)
- dnsmasq software for acting as a DHCP and DNS caching server (package dnsmasq)
The following conditions must also have been met:
- You must have a working ppp connection (I'm using bluetooth+gprs to connect to the Internet)
- You must have a working wlan interface card (in terms of "can be used in Linux")
[edit] Instructions
- Set the ppp connection up.
- Set the wlan connection up. Choose ssid and select ad-hoc as network type. In the following I'm assuming that you are using interface named wlan0 . Set the wlan interface up address for example 192.168.0.254 . Setting up the interface is usually done by running the iwconfig program as root, with syntax like:
iwconfig wlan0 essid "My_Free_Wlan" mode Ad-Hoc
After that you can assign an ip address to the interface as usual, by running (again, as root):ifconfig wlan0 192.168.0.254
Please note that different wlan cards may be configured differently and one should adapt this documentation accordingly. - Set the kernel to router mode. This is done by running as root:
echo 1 > /proc/sys/net/ipv4/ip_forward
- Configure dnsmasqd. Make the following changes to /etc/dnsmasq.conf (uncomment if necessary):
domain-needed bogus-priv interface=wlan0 (or whatever interface your wlan is) dhcp-range=192.168.0.1,192.168.0.100,12h
- Start the dnsmasqd, as root:
/etc/rc.d/dnsmasq start
- Finally, set firewall to forward connections to and from the Internet for clients connecting to your wlan. This is done by issuing (you guessed it right, as root again):
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
In the above the ppp0 interface is the used ppp interface, you can substitute it for yours if needed. - You are done! Happy surfing