Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: floppy on September 02, 2012, 04: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 > .." ?
-
Have you tried that as root (avoid sudo)?
-
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
-
Have you tried that as root (avoid sudo)?
sudo su
echo 1 > /proc/sys/net/ipv4/ip_forward
works. Thanks.
-
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"
-
route add default gw 1.2.3.4
-
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?
-
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
-
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.
-
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.
-
Please elaborate on "nothing happens". If you didn't set up a DHCP server on the masquerading box, any clients will need static IPs.
-
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?
-
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
-
You have no default route.
Perhaps you should get a book on basic Linux networking.
-
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..
-
Building a router is a fairly complex task, and should not be attempted by one not willing to take the time to learn the basics.
-
Building a router is a fairly complex task, and should not be attempted by one not willing to take the time to learn the basics.
I will. Im making progress with colleagues from the development area. I will post the success the next days here. Except somebody here is quicker than my colleagues.
-
If I had such a goal, I would look into existing router distros how they do things, avoiding to try to reinvent the wheel ;)
-
It runs. Im posting here from a PC connected to a LAN, connected to a netbook, connected to the internet via GPRS/UMTS USB. My setup is
Connection shematic
==================================================
PC1 PC2 PCx
\ | /
\ | / netbook
\ | / ---------------------------
-------------------- I NAT Gateway Device I ---------------------
I HUB I------I- eth0 : 192.168.3.5 I I Web provider I
I I I ppp0 $DEF_GW I-----I I
-------------------- --------------------------- ---------------------
Samsung nc10 Plus pinternet.interkom.com
Huawei USB GPRS modem nameserver 8.8.8.8
broadcast 192.168.3.255 nameserver 8.8.4.4
netmask 255.255.255.0 www.fonic.de
gateway 10.64.64.64 = $DEF_GW
commands to be done on the netbook
=================================
tce-load -i iptables.tcz
tce-load -i iproute2.tcz
INT_DEV="eth0"
EXT_DEV="ppp0"
DEF_GW="`/sbin/ifconfig ppp0 | grep 'P-t-P' | awk '{print $3}' | sed -e 's/.*://'`"
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo /sbin/ifconfig eth0 192.168.3.5 broadcast 192.168.3.255 netmask 255.255.255.0
echo dont use 192.168.3.5 for the PCs IP but another like 192.168.3.1 or 2 or 7 ..
sudo /sbin/ifconfig eth0 up
sudo iptables -F
sudo iptables -X
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -A FORWARD -i $INT_DEV -o $EXT_DEV -j ACCEPT
sudo iptables -t nat -A POSTROUTING -o $EXT_DEV -j MASQUERADE
sudo iptables -A FORWARD -i $EXT_DEV -o $INT_DEV -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo route del default
sudo route add default gw $DEF_GW
commands to be done on one PC
=================================
sudo ifconfig eth0 192.168.3.1 broadcast 192.168.3.255 netmask 255.255.255.0
sudo route add default gw 192.168.3.5
echo 192.168.3.5 is the default gateway for eth0 of the netbook router
echo 192.168.3.1 is the IP of the PC you are working on
Attention: the same resolv.conf must be used on PC and netbook.
resolv.conf pinternet.interkom.com
nameserver 8.8.8.8
nameserver 8.8.4.4
Place for improvement: the firewall caracteristics.