LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-22-2011, 08:20 AM   #1
vladimir1986
Member
 
Registered: Jul 2011
Posts: 112

Rep: Reputation: Disabled
Sharing internet connection(wireless server internet, wired network client)


Hi!

I have a special situation, which google coudn't resolve (too noob in networking).

I have an ancient 1999 computer (PIII,450mhz, 512RAM). I want to install Arch or Gentoo on it (yes, i am aware of how masochist is compiling with 450 mhz), that means i need internet. I just have a net card (eth0) on it.

I also have a newer laptop, which i plan to use as server. I don't have the modem on my room, so i am connected to internet via wireless, i also have a wired card,which i alredey use to do connect via ssh to the old computer.

I don't use Iptables, or windows. All the tutorials refer to setting iptables rules, or using winxp, which confuss me. I followed some tutorials skipping the iptables thing, and did:

Router:~# echo 1 > /proc/sys/net/ipv4/ip_forward (to activate fowarding)
Router:~# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE (activate NAT)
added this to /etc/dnsmasq.conf

listen-address=192.168.1.100
bind-interfaces
dhcp-range=192.168.1.2,192.168.1.254,12h

Router:~# /etc/rc.d/dnsmasq restart
Router:~# ifconfig eth0 192.168.1.100 (this is the static ip of my wlan0 interface, connected to internet)

Then, with the client alredy wired, (there is not too much info on this part anywere, so i just imagine the precess)

Client:# ifconfig eth0 192.168.1.100
Client:# dhcpcd eth0
ping www.google.com

Then, it can ping with 100% packet loss, or give me the classic: "Ping: bad adress 'www.google.com'". No Internet anyway.

Thanks in advance
 
Old 07-24-2011, 09:38 PM   #2
MrChilly0
Member
 
Registered: Jan 2007
Location: midwest USA
Distribution: gentoo w/ funtoo overlay
Posts: 146

Rep: Reputation: 23
just a shot in the dark...but if your laptop (router) is @ 192.168.1.100 and is acting as a dhcp server, the address of the old box (client) will be given through the dhcp server and not be the .100 addy. If it is set up right, when you plug in, you can dhcpcd on the server (or dhclient, whatever you have installed) and nab an address.
Also, you will need a cross connect cable (real easy to make with an old ethernet cable) for the connection.
 
Old 07-24-2011, 10:34 PM   #3
Lexus45
Member
 
Registered: Jan 2010
Distribution: Debian, Centos, Ubuntu, Slackware
Posts: 361
Blog Entries: 3

Rep: Reputation: 48
I see 2 problems which may occur:

1. Have you configured in DHCP server the options for default gateway and nameserver?
I think your DHCP-client just got the IP-address and nothing more. It doesn't know how to resolve the FQDNs to IP-addresses, it doesn't know how and where to route the addresses, other than 192.168.1.0/24 subnet.

2. Show please the output of 'iptables -L -v -n' or just 'iptables -L'.

Maybe you need at least one more rule in iptables which will allow the traffic, going through your Linux-box:
iptables -A FORWARD -i <your_wireless_interface> -s <your client's IP address> -o eth0 -j ACCEPT

This will help if your default policy for the FORWARD chain is "DROP".

Last edited by Lexus45; 07-24-2011 at 10:48 PM.
 
Old 07-25-2011, 09:26 AM   #4
vladimir1986
Member
 
Registered: Jul 2011
Posts: 112

Original Poster
Rep: Reputation: Disabled
Hi, and thanks for the answers!

I did the iptables -L -v -n command and the imput whas:

Chain INPUT (policy ACCEPT 1 packets, 1500 bytes)
pkts bytes target prot opt in out source destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination


Then Foward is alredy set in "accept", so the problem must be on the dhcp server. Untill now, i didn't touched it, i even dont knew you could pass it so many options (i just used a generic dhcpcd eth0). Now i am on a hurry and i cant try it, but sounds as easily googleable. If i succed, i will post the solution.

Quote:
Originally Posted by Lexus45 View Post
I see 2 problems which may occur:

1. Have you configured in DHCP server the options for default gateway and nameserver?
I think your DHCP-client just got the IP-address and nothing more. It doesn't know how to resolve the FQDNs to IP-addresses, it doesn't know how and where to route the addresses, other than 192.168.1.0/24 subnet.

2. Show please the output of 'iptables -L -v -n' or just 'iptables -L'.

Maybe you need at least one more rule in iptables which will allow the traffic, going through your Linux-box:
iptables -A FORWARD -i <your_wireless_interface> -s <your client's IP address> -o eth0 -j ACCEPT

This will help if your default policy for the FORWARD chain is "DROP".

Last edited by vladimir1986; 07-25-2011 at 10:35 AM.
 
Old 07-25-2011, 10:34 AM   #5
vladimir1986
Member
 
Registered: Jul 2011
Posts: 112

Original Poster
Rep: Reputation: Disabled
DID IT!!

i followed arch wiki manual, i am amazed on how much documentation it has (or maybe i didn't rely enought on internet). I am pretty sure this will work for every distro with a net card and iptables

# ifconfig eth0 192.168.0.1 netmask 255.255.255.0 --> just replace eth0 with the card name where you plugged the network wire to client
# ifconfig eth1 up

echo 1 > /proc/sys/net/ipv4/ip_forward --> (i also edited /etc/sysctl.conf to make it persistent on reboot, just adapt it to your distro "net.ipv4.ip_forward=1")

iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE -->there whas part of the problem. I did it on eth0, not wlan0, where is working the internet connection
/etc/rc.d/iptables save -->adapt /etc/rc.d to what your distro uses for store the daemons

Edit /etc/conf.d/iptables and enable IP forwarding there (IPTABLES_FORWARD=1) --> (Same, each distro has the iptables conf on a different place, but the idea is the same)
/etc/rc.d/iptables restart --> restart iptables daemon, or reboot

cat /etc/resolv.conf --> (for use on the client lather)

ON THE CLIENT


ifconfig eth0 192.168.0.2 netmask 255.255.255.0
ifconfig eth0 up
route add default gw 192.168.0.1 eth0
echo "nameserver <adr of nameserver>" >> /etc/resolv.conf (copy the first DNS on the server machine when you did cat /etc/resolv.conf)
ping www.google.com

Profit
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux to PC wired ad hoc network with internet sharing onlyhtml Linux - Networking 2 03-12-2011 11:38 AM
Wired networking not connecting in Fedora 12 with Windows Internet Connection Sharing LinuxLearner123 Linux - Networking 2 01-16-2011 05:33 PM
sharing internet connection to thin client from RHEL server 5 sam1230 Linux - Networking 2 09-22-2010 03:45 PM
Internet Connection Sharing for Private Wireless Network kanwar_rajan Linux - Wireless Networking 0 09-18-2007 12:37 PM
Sharing an internet connection with a Linux client through a 2000 server gateway thuan Linux - Networking 1 08-02-2001 01:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration