LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-16-2009, 04:58 AM   #1
sysslack
Member
 
Registered: Feb 2006
Posts: 69

Rep: Reputation: 15
NAT eth0 through wlan0?


Hi
computer1 running CentOS5

nic eth0 connected to computer 2
nic wlan0 connection to internet

computer2 running Debian lenny

nic eth0 connected to computer1 through cross cable

Is it possible to surf the internet from computer2 with this setup ?
I have tried with this rules on computer1, but it did not work
root@localhost ~]# iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
[root@localhost ~]# echo 1 > /proc/sys/net/ipv4/ip_forward

Computer1
root@localhost ~]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.2.0 * 255.255.255.0 U 0 0 0 wlan0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
default 192.168.2.254 0.0.0.0 UG 0 0 0 wlan0

[root@localhost ~]# ifconfig
eth0 inet addr:192.168.0.5 Bcast:192.168.0.255 Mask:255.255.255.0
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
wlan0 inet addr:192.168.2.12 Bcast:192.168.2.255 Mask:255.255.255.0


Computer2
# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0

root# ifconfig

eth0 inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0

Last edited by sysslack; 08-16-2009 at 05:34 AM.
 
Old 08-16-2009, 07:54 AM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Could you provide information on your wireless connection? If you are using a wireless NAT router, you can have the wired connection on a subnet and use forwarding. If your router is a nat router, you don't need to configure masquerading on the first computer (with wireless). The router can do it.

I did this once to share wireless connection on my laptop, for my desktop. You need to enable ip forwarding. I found that I also needed to load the conntrack module to get it to work. (was called ip_conntrack but now is called nf_conntrack)
You may be able to enable ip forwarding in your distro's device configuration, or in a boot up script that includes the line:
echo 1 >/proc/sys/net/ipv4/ip_forward
 
Old 08-17-2009, 06:37 AM   #3
sysslack
Member
 
Registered: Feb 2006
Posts: 69

Original Poster
Rep: Reputation: 15
Thank you for your answer!I guess I am missing module nf_conntrack
 
  


Reply

Tags
eth0, nat, wlan0


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
how to forward wlan0 to eth0? patcito Linux - Networking 2 07-03-2009 05:26 AM
dhcp wlan0 before eth0? datadriven Slackware 2 01-22-2009 12:26 PM
wlan0 doesn't work without eth0? linuxhippy Fedora 8 07-26-2005 07:43 PM
Remapping wlan0 to eth0 Berhanie Linux - Networking 1 02-17-2005 07:59 AM
route wlan0 to eth0 hwood7587 Linux - Networking 1 07-13-2003 06:47 PM


All times are GMT -5. The time now is 05:57 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration