LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Internet sharing from ppp0 to uap0 [Hotspot] in linux based embedded board (https://www.linuxquestions.org/questions/linux-networking-3/internet-sharing-from-ppp0-to-uap0-%5Bhotspot%5D-in-linux-based-embedded-board-4175662960/)

Sphinix 10-22-2019 07:39 AM

Internet sharing from ppp0 to uap0 [Hotspot] in linux based embedded board
 
Hi,

I am working on a task ,internet sharing between two interfaces ppp0 and uap0 which is the hotspot interface .

ppp0 gets internet connection . I am able to ping google. And the IP here keeps on changing

uap0 is the interface which is used for hotspot connection of the board. I have set an IP of 192.168.10.1 to this interface and runs an dhcp server. My phone gets connected to the board via uap0 and gets an IP of 192.168.10.2

I am expecting an internet connection in my phone. But it is not happening

internet <-----> ppp0 <-----> uap0 <-----> phone

Once both the interfaces are up , my routing table is something like this
Code:

  Kernel IP routing table
  Destination    Gateway        Genmask        Flags Metric Ref    Use Iface

  0.0.0.0        0.0.0.0        0.0.0.0        U    0      0        0 ppp0

  192.168.10.0    0.0.0.0        255.255.255.0  U    0      0        0 uap0

And I tried below iptable rules
Code:

echo 0 > /proc/sys/net/ipv4/ip_forward
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -I PREROUTING -i ppp0 -j DNAT --to-destination 192.168.10.0
iptables  -A FORWARD -m state --state ESTABLISHED -j ACCEPT
iptables -A FORWARD -t filter -i ppp0 -o uap0 -s 10.212.17.0 -p tcp --dport 8
iptables -A FORWARD -t filter -i uap0 -o ppp0 -d 192.168.10.0 -p tcp --sport 80
iptables -t nat -A POSTROUTING -o ppp0 -s 192.168.10.0/24 -j SNAT --to-source 10.212.17.0
echo 1 > /proc/sys/net/ipv4/ip_forward

When I checked whether iptable rules are getting hit, there are no forward packets getting incremented

Whether the iptable rules are proper.? Or should I make any changed to the routing table. I am a newbie to
iptables and NAT related concepts.

Any help would be appreciated.

business_kid 10-22-2019 10:03 AM

ppp0 needs to forward it's own traffic to the internet, and I gather that's happening.

uap0 needs to forward everything to ppp0. Is that happening? are uap0 & ppp0 on the same box?

uap0 also needs to run a dhcp server. The kernel may need to have ipv4 forwarding enabled.

Now I don't wan to do your homework for you. So in the words of Jean-Luc Picard: "Makeit So!"

Sphinix 10-22-2019 11:47 PM

Thanks for the reply.

-> uap0 needs to forward everything to ppp0. Is that happening? are uap0 & ppp0 on the same box?

uap0 and ppp0 belongs to a single board. From the output of "watch -n1 iptables -vL", the forward packets count is zero. So I concluded the forwarding is not happening.

-> uap0 also needs to run a dhcp server. The kernel may need to have ipv4 forwarding enabled.

Sphinix 10-22-2019 11:47 PM

Hi ,

Thanks for the reply.

-> ppp0 needs to forward it's own traffic to the internet, and I gather that's happening.

Yup. This is happening.

-> uap0 needs to forward everything to ppp0. Is that happening? are uap0 & ppp0 on the same box?

From the output of "watch -n1 iptables -vL I can see no increment in number of packets forwarded . I believe,packet forwarding is something that need attention
uap0 and ppp0 belong to same board

->uap0 also needs to run a dhcp server. The kernel may need to have ipv4 forwarding enabled.

uap0 has a dhcp server running. Also I have enabled the ipv4 forwarding using "echo 1 > /proc/sys/net/ipv4/ip_forward" . And routing related macros in Kernel are enabled and rechecked. I wonder is there anything else which contribute to ip forwarding and that exactly I am missing

business_kid 10-24-2019 04:48 AM

A few things can hold you up.

Off the top of my head
  • Your kernel routing table. uap0 needs to funnel stuff to ppp0. ppp0 needs to see the outside world. Programs are inclined to hack this every time, so be careful.
  • Your dhcp server needs to have and forward dns server numbers to everything that signs on unless you're also running a dns server.


All times are GMT -5. The time now is 04:35 AM.