Author Topic: SOLVED How do I share wifi internet with non-wifi machine?  (Read 2218 times)

Offline Phil

  • Hero Member
  • *****
  • Posts: 738
Re: How do I share wifi internet with non-wifi machine?
« Reply #15 on: November 21, 2012, 04:03:07 AM »

In PCC there is a section Network > Share the internet connection.

(I am interested in this, maybe a write up in Tips & Tricks)

Ordinary network cable the two ends match.

Cross Over cable (for machine to machine) two of the strands are switched so the ends do not match)

Offline Jimbo

  • Full Member
  • ***
  • Posts: 134
Re: How do I share wifi internet with non-wifi machine?
« Reply #16 on: November 21, 2012, 04:46:53 AM »
OK, I'm too tired for any more tonight.  So far I have twice used the PCC "Share the internet connection" button, agreeing with all the defaults (as I don't know what else to do).  First time it installed several things, including squid, whatever that is.  Each time I shared the internet connection it has stopped my laptop accessing the internet.  I have had to re-run the "Share the internet connection" wizard, cancelling the sharing, before I have got internet back on the laptop.  If I don't have it on the laptop, however can the desktop get it through the laptop?
As well as which, I have no idea of how to set up a lan between the laptop and the desktop using the crossover cable.  Sure they can ping each other, but what happens from there?
What seems a simple idea is becoming very complicated!
Thanks for all your help, and goodnight.

Offline Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10613
  • MLUs Forever!
Re: How do I share wifi internet with non-wifi machine?
« Reply #17 on: November 21, 2012, 09:39:17 AM »

In PCC there is a section Network > Share the internet connection.

(I am interested in this, maybe a write up in Tips & Tricks)

Ordinary network cable the two ends match.

Cross Over cable (for machine to machine) two of the strands are switched so the ends do not match)



IIRC, there is no need for a crossover cable these days .....  not for many years if my memory serves me as it should. All recent NICS should be quite capable of connecting to each other through a standard cat5/cat6  cable.

****

Jimbo,
             The laptop was able to ping the Desktop ......  did you have a similar result pinging the Laptop from the Desktop?

If the Desktop IP is  169.254.140.128, what is the Laptop IP address?


muungwana,
                      does the internet connected PC also need to run a DHCP server to issue an IP address to the other pc, or else should a fixed IP address be set there?


I have not set this up myself, have always used routers ......

MLUs rule the roost!

Linux XPS 3.2.18-pclos2.pae.bfs  32 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Ramchu

  • Hero Member
  • *****
  • Posts: 1588
Re: How do I share wifi internet with non-wifi machine?
« Reply #18 on: November 21, 2012, 11:35:23 AM »
I read this thread and decided to give it a try, and I am now posting from my Desktop computer
that is hardwired to my laptop, using a normal ( not a crossover ) cable, with the laptop connected to my router
via Wifi.
I found that after I had set up internet connection sharing in PCC that I had to reset my firewall on both machines a couple of times,as I was setting up internet sharing it said that bind and squid needed to be installed - ok.
Also looking at my ip address on the laptop it is 192.168.1.101 and on my connected desktop it is 192.168.1.102
When the desktop first connected to the laptop it took a looong time for it to connect but when it did I got the connection
Icon in the system tray, but then Firefox would not connect to any website, until I reset the firewall.

It sounds like the original poster is using a Wifi HotSpot device which should work nearly the same as a Wireless Router.

Quote
muungwana,
                      does the internet connected PC also need to run a DHCP server to issue an IP address to the other pc, or else should a fixed IP address be set there?
The DHCP server is all that is needed.
__________________________________________________________________________
EDIT: If the Laptop is rebooted,hibernated or put into sleep mode it is not a reliable connection.
« Last Edit: November 21, 2012, 12:01:55 PM by Ramchu »

Offline jaydot

  • Administrator
  • Super Villain
  • *****
  • Posts: 15565
  • there is no limitation on imagination
Re: How do I share wifi internet with non-wifi machine?
« Reply #19 on: November 21, 2012, 02:59:21 PM »
jimbo, ping the laptop with the desktop.  or open a browser and see if you can surf on the desktop.  if you can, you're done.
PCLinuxOS  Get it?  Got it?  Good!!   8)

We don't have any millionare angels or corporate backers paying the bills here, PLEASE DONATE.
http://pclinuxos.com/?page_id=7

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6214
Re: How do I share wifi internet with non-wifi machine?
« Reply #20 on: November 21, 2012, 04:08:28 PM »
The laptop was able to ping the Desktop ......  did you have a similar result pinging the Laptop from the Desktop?

If the Desktop IP is  169.254.140.128, what is the Laptop IP address?

muungwana,
                      does the internet connected PC also need to run a DHCP server to issue an IP address to the other pc, or else should a fixed IP address be set there?


I have not set this up myself, have always used routers ......



A successful ping means a packet was received on the other end and an acknowledgment that a packet was received from the other end was received. A successful ping means a connection means two computers can see and talk to each other.Ping working on one end and not the other end means a deliberate dropping of ping requests by a firewall and not a connection problem.

I think the pcc procedure to set up network sharing should also install and configure a dhcp server.I dont think it currently does that and hence a manual installation and configuration of it or a manual setting of static IP address is required.

But the original poster is not having a dhcp related problem.His internet connection get broken when he set it up for some reason.
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline DeBaas

  • Hero Member
  • *****
  • Posts: 1516
    • PCLinuxOS.nl
Re: How do I share wifi internet with non-wifi machine?
« Reply #21 on: November 21, 2012, 04:30:40 PM »
ip route in command line.

http://linux-ip.net/html/routing-tables.html

And I know it is'nt easy for a Linux starter.

So try internetsharing in PCC first.

Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3979
Re: How do I share wifi internet with non-wifi machine?
« Reply #22 on: November 21, 2012, 05:38:55 PM »
The use of iptables in the command line is a lot easier and less processor-intensive than the PCC method!

The PCC method will set your laptop up as a proxy server, complete with its own webserver and DNS. The iptables method simply arranges NAT forwarding of packets between two devices - in this case the ethernet and the wireless lan.

You should start by setting up both laptop and desktop's eth0 in PCC to have different IP addresses in one of the private blackhole blocks, and different from the address range used by the wireless lan. The wlan is probably in the 192.168. range so it might be good to pick addresses in the 10. range, say 10.1.0.1 for the laptop and 10.1.0.2 for the desktop. Connect them together and make sure you can ping each machine from the other. Then hover the mouse over the netapplet on the laptop and set the DNS address for the desktop's eth0 to the value you see there.

Then, as root put the following lines into a script in /etc/init.d/ called, say inetforward:
Code: [Select]
#!/bin/sh

# local Shell script to NAT wireless to laptop by ethernet

# chkconfig: 35 28 62
# description:

### BEGIN INIT INFO
# Provides:          inetforward
# Required-Start:    $network $shorewall
# Required-Stop:     $network  $shorewall
# Default-Start:     3 5
# Default-Stop:      0 1 2 4 6
# Short-Description: Start Internet forwarding
# Description:       Control Internet forwarding to desktop
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

# Lock files
SYSCONF_FILE=/var/lock/subsys/natted

# Other Services
EXTERNAL_SERVER_IP=10.1.0.2
ROUTING_DELAY=20

start_forwarding () {
  # Now set up NAT
  echo 1 > /proc/sys/net/ipv4/ip_forward
  iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
  /sbin/iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
  /sbin/iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
}

stop_forwarding () {
  iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE
  /sbin/iptables -D FORWARD -i eth0 -o wlan0 -j ACCEPT
  /sbin/iptables -D FORWARD -i wlan0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
  echo 0 > /proc/sys/net/ipv4/ip_forward
}

start () {
if [ -f $SYSCONF_FILE ]; then
gprintf "Already natted\n"
exit 1
fi
# Work round broken start order
sleep $ROUTING_DELAY
start_forwarding
touch $SYSCONF_FILE
}

stop () {
if [ -f $SYSCONF_FILE ]; then
stop_forwarding
rm -f $SYSCONF_FILE
else
gprintf "Not natted\n"
fi
}

case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
;;
status)
if [ -f $SYSCONF_FILE ]; then
echo 'natted'
exit 0
else
echo 'Not natted'
exit 1
fi
;;
*)
echo "Usage: $0 [start|stop|restart|status]"
exit -1
esac

exit 0

Finally, go to the PCC ->System ->Control Services area and set the inetforward service to start at boot.

If all is well, both machines should now be connected.
-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline Jimbo

  • Full Member
  • ***
  • Posts: 134
Re: How do I share wifi internet with non-wifi machine?
« Reply #23 on: November 22, 2012, 01:02:45 AM »
Thanks to you all for your kind suggestions.
I don't have time to work on the project for the next couple of days, but hope to attack it again Saturday evening.  Will let you know how it goes!

Offline Jimbo

  • Full Member
  • ***
  • Posts: 134
Re: How do I share wifi internet with non-wifi machine?
« Reply #24 on: November 24, 2012, 01:32:57 AM »
kjpetrie, it seems to me that your way of doing things would be the simplest, but I have run into a few problems.  I'll try to put them in the right order.
First, some information.
Output of ifconfig on the laptop:
eth0      Link encap:Ethernet  HWaddr 70:F3:95:B7:89:78 
          inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::72f3:95ff:feb7:8978/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:904 errors:0 dropped:0 overruns:0 frame:6258
          TX packets:889 errors:4 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:483852 (472.5 KiB)  TX bytes:182849 (178.5 KiB)
          Interrupt:17

eth1      Link encap:Ethernet  HWaddr 64:31:50:54:42:48 
          inet addr:10.1.0.1  Bcast:10.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::6631:50ff:fe54:4248/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:30 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:8779 (8.5 KiB)  TX bytes:6475 (6.3 KiB)
          Interrupt:42 Base address:0xa000

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Output of ifconfig on the desktop:

eth0      Link encap:Ethernet  HWaddr 00:13:D4:60:B1:1D 
          inet addr:10.1.0.2  Bcast:10.255.255.255  Mask:255.0.0.0
          inet6 addr: fe80::213:d4ff:fe60:b11d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:468 (468.0 b)  TX bytes:10015 (9.7 KiB)
          Interrupt:19 Base address:0x8c00

lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

Laptop can ping desktop and vice versa.

You will note that on the laptop the wireless internet connection is actually eth0.  The wired connection to my desktop is eth1.

When I hover over the netapplet on the laptop it only shows the wireless DNS.  No details at all of the connection to the desktop.

Hovering over the netapplet on the desktop says "Network is down on interface Wired (Ethernet) (wwan0)".

However, each can ping the other.  Output of ping from laptop to desktop is:
PING 10.1.0.1 (10.1.0.1) 56(84) bytes of data.
64 bytes from 10.1.0.1: icmp_req=1 ttl=64 time=0.090 ms

--- 10.1.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.090/0.090/0.090/0.000 ms

On the laptop, as root, I copied and pasted the text you sent me into a file named inetforward, put it in /etc/init.d/ and using PCC set it to start at boot.
(I think some lines should be changed, as the wireless is on eth0, not wlan0, but don't know enough to know exactly what to change.)

I rebooted, but although I can still ping from one machine to the other, they don't seem to be fully connected.  My guess is because I don't know the DNS of the desktop to enter in the eth1 configuration of the laptop.

Also, in PCC, the inetforward script is no longer ticked to start at boot.  Don't know why.  When I try to start it now I get the message "env /etc/init.d/inetforward: Permission denied".  I have checked permissions for inetforward - owner is root and both owner and group can read and write.

Hope this information is helpful, and thanks to all of you for your interest and suggestions.  Please keep them coming!

Offline kjpetrie

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3979
Re: How do I share wifi internet with non-wifi machine?
« Reply #25 on: November 24, 2012, 04:11:30 AM »
The first thing is to ensure the execute permission is set for the inetforward  script:
-rwxr--r-- or -rwxr-xr-x.

That script needs to run on the laptop. (The machine with Internet access - not sure I made that clear.)

Have you adjusted my instructions for the fact my wlan0 is actually eth0 and my eth0 is eth1? I presume you have.

Finally, you need to set the desktop's DNS to use what the laptop uses, which you can usually discover by hovering over netapplet in the laptop.

Shorewall needs to be set to start on boot on the laptop.

Hope at least one of those points helps.
-----------
KJP
-----------------------------------------------------------
PClos64 RC1 on Intel D945GCLF2 motherboard (Atom 330), 2GB DDR2 RAM, Maxtor STM325031, HL-DT-ST DVDRAM GSA-H42N, Amilo LSL 3220T monitor. Also Acer 5810TG (with custom kernel) and Asus eeePC 2G surf

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6214
Re: How do I share wifi internet with non-wifi machine?
« Reply #26 on: November 24, 2012, 10:24:57 AM »
kjpetrie instructions forgot to mention "default gateway".

on the desktop,the default gateway must be the IP address of the other computer it is connecting to.In your case,it must be "10.1.0.1"

reconfigure "eth0" on the desktop,choose "manual configuration" and enter enter "10.1.0.1" as gateway address in the appropriate field.The rest of the fields should as above in your output,your desktop should now be able to go online

after that,post the output of

route -n

ps:
It is not necessary for DNS to match.
What is necessary is for the desktop to send its traffic to the laptop and have the laptop forward it to the internel.
« Last Edit: November 24, 2012, 10:26:28 AM by muungwana »
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..

Offline Jimbo

  • Full Member
  • ***
  • Posts: 134
Re: How do I share wifi internet with non-wifi machine?
« Reply #27 on: November 24, 2012, 03:02:55 PM »
Thanks kjpetrie and muungwanna for your help.

kjpetrie, when I try to run the inetforward script in PCC now, I get the following message:

/etc/init.d/inetforward: line 74: syntax error near unexpected token ';;'
/etc/init.d/inetforward: line 74 ';;'

Does this matter?
Also, although I ticked the "on boot" box beside it in PCC, when I rebooted I see that it is now not ticked.

Thanks again,
Jim

Offline Jimbo

  • Full Member
  • ***
  • Posts: 134
Re: How do I share wifi internet with non-wifi machine?
« Reply #28 on: November 24, 2012, 04:13:02 PM »
Further to above post:
I deleted line 74, which appeared to be the same as the line above it.
Now when I start the script in PCC it seems to run, but eventually comes up with the message "Not natted"
The laptop and desktop seem to be connected, and the netapplet on the desktop now says network is up, but can't connect to the inernet, probably because the inetforward script is not quite working.

Offline muungwana

  • Hero Member
  • *****
  • Posts: 6214
Re: How do I share wifi internet with non-wifi machine?
« Reply #29 on: November 24, 2012, 04:47:01 PM »

you did not post output of the below command from the desktop computer:

route -n

you can simply copy the commands that are being executed at the service start up.

open the terminal,log in as root and then run these commands and try again.
Quote
echo 1 > /proc/sys/net/ipv4/ip_forward
/sbin/iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE

run this command when you are done with above and post its output

iptables -t nat -L -v

ps:
I do not think others are necessary.
I also think "-I" is a better option than "-A" since with it,you know the rule you added is at the top of the list and will be effective,with "-A",it may or may not be effective depending on rules that above it.
« Last Edit: November 24, 2012, 04:50:13 PM by muungwana »
.. 3 things are certain in life : death, taxes and software bloat ..
.. tell me something i don't know, something i can use as i struggle to reason with the world around me ..