WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: (solved) HOWTO setup netbook+GPRS USB like LAN router?  (Read 9847 times)

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
(solved) HOWTO setup netbook+GPRS USB like LAN router?
« on: September 02, 2012, 01:06:14 PM »
I would like to connect other PCs to my netbooks LAN connector; the netbook is connected to the internet with my Huawei USB GPRS modem.

according a recommendation, following should work:
=============================
Enable ip forwarding, configure nat and any firewall rules you might want, install a default route on all connected machines pointing at the internal interface of the netbook and you are done.

 echo 1 > /proc/sys/net/ipv4/ip_forward

 iptables -t nat -A POSTROUTING -o your_outside_interface_name_here -j MASQUERADE

 ip route add default via 1.2.3.4 for a linux host
 route add 0.0.0.0 mask 0.0.0.0 1.2.3.4 for a windows host, in command prompt - not sure what the gui alternative is
 1.2.3.4 should obv be replaced with yor internal address on the netbook.
=============================

I made:
 - boot my samsung nc10 plus via SD card and TinyCoreLinux 4.5.6
 - goes into the net (or not) via GPRS USB (Huawei modem)
 - With the command "echo 1 > /proc/sys/net/ipv4/ip_forward", I get the error
 "sh: can't create /proc/sys/net/ipv4/ip_forward: Permission denied"
 - A "sudo echo 1 ..." gives the same error
 - "cat /proc/sys/net/ipv4/ip_forward" gives a "0" as output

So, what is wrong here? A TinyCore specific command should be used instead of "echo 1 > .." ?
« Last Edit: September 22, 2012, 07:28:14 AM by floppy »
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #1 on: September 02, 2012, 01:34:02 PM »
Have you tried that as root (avoid sudo)?
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline hiro

  • Hero Member
  • *****
  • Posts: 1228
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #2 on: September 02, 2012, 01:51:53 PM »
if your shell doesn't have the rights shell redirction won't work.
but you can use tee
echo 1 | sudo tee  /proc/sys/net/ipv4/ip_forward

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #3 on: September 02, 2012, 02:12:01 PM »
Have you tried that as root (avoid sudo)?
sudo su
echo 1 > /proc/sys/net/ipv4/ip_forward

works. Thanks.
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #4 on: September 03, 2012, 01:43:05 PM »
Hello,
know somebody how to realize the recommendation " ip route add default via 1.2.3.4 for a linux host" in TinyCore?
I made "ip route add default via 8.8.8.8" in a terminal but it says "sh: ip: not found"
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #5 on: September 03, 2012, 01:46:28 PM »
route add default gw 1.2.3.4

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #6 on: September 04, 2012, 01:37:15 PM »
I made "iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE" in a terminal in the netbook.

"route -n" on the netbook gave

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
10.64.64.64     0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
127.0.0.1       0.0.0.0         255.255.255.255 UH    0      0        0 lo

So, I was thinking about using 10.64.64.64 instead of 1.2.3.4.

I made "route add default gw 10.64.64.64" in the netbook

Then now, "route -n" gives

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.64.64.64     0.0.0.0         UG    0      0        0 ppp0
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 ppp0
10.64.64.64     0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
127.0.0.1       0.0.0.0         255.255.255.255 UH    0      0        0 lo

When I connect the PC to the netbook via LAN, the PC see a LAN connection (eth0).
But "ping -c 4 www.google.de" in a PC terminal says "bad address"

Perhaps it is a question of resolv.conf?
The content of it in the PC is:
search fritz.box
nameserver 192.168.178.1

I doubt the content is correct. Which content it should be?
« Last Edit: September 04, 2012, 01:41:36 PM by floppy »
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #7 on: September 04, 2012, 06:56:01 PM »
Without knowing much about iptables, but having a different private subnet IP for nameserver vs. default gateway seems suspicious.

Same with default gateway 0.0.0.0
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #8 on: September 05, 2012, 01:57:44 PM »
thanks. 0.0.0.0 did not help.

remark 1: when the netbook with GPRS USB is connecting, I see the message
Local IP 10.57.114.162
Remote IP 10.64.64.64 (we have it in previous posts)
Primary DNS 10.11.12.13
Secondary DNS 10.11.12.14

remark2: the service dhcp was not "on" in the previous post.

I will have a deeper look with Mr. Google.
Not so easy that setup.
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #9 on: September 10, 2012, 01:28:54 PM »
Here I found something http://www.aboutdebian.com/proxy.htm
and adapted it for TinyCore

I used the script on my netbook...

#!/bin/sh
INTIF="eth0"
EXTIF="ppp0"
EXTIP="`/sbin/ifconfig ppp0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`"
tce-load -i iptables.tcz
echo 1 | sudo tee  /proc/sys/net/ipv4/ip_forward
echo 1 | sudo tee  /proc/sys/net/ipv4/ip_dynaddr
sudo iptables -P INPUT ACCEPT
sudo iptables -F INPUT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F OUTPUT
sudo iptables -P FORWARD DROP
sudo iptables -F FORWARD
sudo iptables -t nat -F
sudo iptables -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

But when I connect  a PC to my netbook via LAN, nothing happens.
Any advice is welcome.
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10982
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #10 on: September 10, 2012, 11:37:51 PM »
Please elaborate on "nothing happens". If you didn't set up a DHCP server on the masquerading box, any clients will need static IPs.
The only barriers that can stop you are the ones you create yourself.

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #11 on: September 11, 2012, 02:17:20 PM »
Please elaborate on "nothing happens". If you didn't set up a DHCP server on the masquerading box, any clients will need static IPs.
You are right; the message was a bit poor but very late in the evening.. Im on the way to post a full diagnosis file the next days (Im sticking on creating outputs like ip address show etc.): before and after the setup (for the GPRS-USB to LAN netbook-server and for a PC at the LAN-connector via a LAN-5-Connector-box).
I had no DHCP  on the netbook (= GPRS-USB to LAN router).
So, a static IP would have to be used? perhaps 10.64.64.64?
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #12 on: September 13, 2012, 02:08:51 PM »
With router.sh
I got he log file router.log (see attachments)
Another PC connected to a hub which is connected to the router netbook still dont see the internet.

route -n   gives
127.0.0.1   0.0.0.0   255.255.255.255. UH 0 0 0 lo

ifconfig
eth0 Ethernet UP BROADCAST RUNNING.. TX bytes are increasing with the time. TX packets: 105 all others 0..
lo   see http://imagebin.org/228351
« Last Edit: September 13, 2012, 02:14:17 PM by floppy »
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #13 on: September 13, 2012, 02:11:37 PM »
You have no default route.
Perhaps you should get a book on basic Linux networking.

Offline floppy

  • Hero Member
  • *****
  • Posts: 577
Re: how to setup my netbook+GPRS USB as a LAN router?
« Reply #14 on: September 13, 2012, 02:15:55 PM »
You have no default route.
Perhaps you should get a book on basic Linux networking.
youre probably right.
you mean a default route in the PC connected to the netbook-router?
which full command?
Im learning by doing few and jumping from localized issue to another localized issue. so, no time for a wide linux seminar..
« Last Edit: September 13, 2012, 02:21:13 PM by floppy »
AMD K6-IIIATZ 550MHz MB DFI K6xv3/+66
P4 HP DC7100 3GB 3GHz
Samsung NC10 boot from SD card port (via USB reader)
.. all TinyCore proofed