0

I have started internet in my Raspberry Pi using USB internet dongle. Then I have make connection of Raspberry Pi to router via LAN cable.

Now I want to share Internet on router. It means Those user who are connecting on "Router" can access internet which is running on "Raspberry Pi"

How can I achieve? Please help. I don't have an idea.

Thanks.

closed as off-topic by goldilocks Jul 8 '15 at 13:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be specific to the Raspberry Pi within the scope defined in the help center." – goldilocks
If this question can be reworded to fit the rules in the help center, please edit the question.

1

Yo have got to set a Wifi AP - Instructables - and tell the router to be a wireless client (maybe your router can't do it, it is easier with a wireless repeater), then the router will share connection with de Banana.

In other way, you can install openwrt - Openwrt Wiki -, and share Internet via cable to router if it can get DHCP in any port.

1

Sounds like what you're trying to do is share your RPi's network connection. In Linux this is called "IP masquerading". There are a ton of articles out there. I think these instructions accomplish what you're trying to do. From that post, this is a script that configures iptables, the system on Linux that manages network connections:

#!/bin/sh
IPT=/sbin/iptables
LOCAL_IFACE=eth0
INET_IFACE=wlan0
INET_ADDRESS=192.168.1.98

# Flush the tables
$IPT -F INPUT
$IPT -F OUTPUT
$IPT -F FORWARD

$IPT -t nat -P PREROUTING ACCEPT
$IPT -t nat -P POSTROUTING ACCEPT
$IPT -t nat -P OUTPUT ACCEPT

# Allow forwarding packets:
$IPT -A FORWARD -p ALL -i $LOCAL_IFACE -j ACCEPT
$IPT -A FORWARD -i $INET_IFACE -m state --state ESTABLISHED,RELATED -j ACCEPT

# Packet masquerading
$IPT -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_ADDRESS

Make sure you update LOCAL_IFACE, INET_IFACE, and INET_ADDRESS to match your RPi's configuration.

Save that file on your RPi, say /usr/local/bin/iptables-setup and run it once. After, run the command iptables-save and you should see something like this:

*filter
:INPUT ACCEPT [73:5085]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [72:6792]
-A FORWARD -i eth0 -j ACCEPT
-A FORWARD -i wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [43:2584]
:INPUT ACCEPT [2:278]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o wlan0 -j SNAT --to-source 192.168.1.98
COMMIT

Add the following to /etc/sysctl.conf and then run sysctl --system:

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

Not the answer you're looking for? Browse other questions tagged or ask your own question.