LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-31-2008, 05:45 AM   #1
aukuntin
LQ Newbie
 
Registered: Jul 2005
Location: Hong Kong
Distribution: LFS with latest software
Posts: 13

Rep: Reputation: 0
Unhappy Nat problem


Hi

I have two computers

Here is my network configuration of the main one:
eth0: external network (DHCP ip)
eth1: internal (192.168.0.1)

I have another computer connected by cross cable to eth1 with ip 192.168.0.2
Each computer can "ping" (communicate) each other

Then I set up a Nat server at the main computer , I run these scripts at startup

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.0.0/24 -j MASQUERADE
dnsmasq

Then here is the problem, I can't connect to network on the second computer.


Main system configuration
Kernel: 2.6.26
Distro: Linuxfromscratch
Modules list:

Module Size Used by
ipt_MASQUERADE 3136 1
iptable_nat 6224 1
nf_nat 18128 2 ipt_MASQUERADE,iptable_nat
nf_conntrack_ipv4 15448 3 iptable_nat,nf_nat
nf_conntrack 56256 4 ipt_MASQUERADE,iptable_nat,nf_nat,nf_conntrack_ipv4
ip_tables 17232 1 iptable_nat
x_tables 19016 3 ipt_MASQUERADE,iptable_nat,ip_tables
saa7134_alsa 12256 0
snd_hda_intel 343508 0
snd_pcm 69004 2 saa7134_alsa,snd_hda_intel
snd_timer 21000 1 snd_pcm
snd_page_alloc 8720 2 snd_hda_intel,snd_pcm
snd_hwdep 8456 1 snd_hda_intel
snd 59848 5 saa7134_alsa,snd_hda_intel,snd_pcm,snd_timer,snd_hwdep
soundcore 6880 1 snd
fglrx 2019532 25
tuner 27532 0
tea5767 7108 1 tuner
tda8290 14084 1 tuner
tuner_xc2028 21872 1 tuner
xc5000 11716 1 tuner
tda9887 11140 1 tuner
tuner_simple 15188 1 tuner
tuner_types 17472 1 tuner_simple
mt20xx 13384 1 tuner
tea5761 5188 1 tuner
saa7134 153564 1 saa7134_alsa
compat_ioctl32 9216 1 saa7134
videodev 32192 3 tuner,saa7134,compat_ioctl32
v4l1_compat 16004 1 videodev
v4l2_common 11520 2 tuner,saa7134
videobuf_dma_sg 11908 2 saa7134_alsa,saa7134
videobuf_core 17412 2 saa7134,videobuf_dma_sg
ir_kbd_i2c 9552 1 saa7134
ir_common 37316 2 saa7134,ir_kbd_i2c
tveeprom 14852 1 saa7134
r8169 27204 0
3c59x 43764 0
mii 5312 1 3c59x
unix 26288 34


Is there something wrong with the modules or the scripts?
 
Old 09-01-2008, 12:08 AM   #2
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
Quote:
I have another computer connected by cross cable to eth1 with ip 192.168.0.2
Does this computer get its IP from DHCP (i.e. from dnsmasq on PC 1 ) ? If so it should automatically set it's default gateway to the IP of PC1 (192.168.0.1). You can check this with the route command on PC2.

Also check your /etc/dnsmasq.conf to make sure it's setup correctly for DHCP if thats what your going for.

If you are assigning a static IP on PC2 you will have to set the default gateway to be 192.168.1.1 yourself with route (along with DNS name server entries in /etc/resolv.conf). You may of course have dnsmasq give out a static IP to PC2 by setting up /etc/dnsmasq.conf to always pass out a particular ip to its Mac address.
 
Old 09-01-2008, 01:20 AM   #3
aukuntin
LQ Newbie
 
Registered: Jul 2005
Location: Hong Kong
Distribution: LFS with latest software
Posts: 13

Original Poster
Rep: Reputation: 0
Thank you bgeddy !!

It seems that I need to set the route on PC2

I do:
ip route add default via 192.168.0.1

Then it works

Thanks for reminding me!
 
  


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
NAT problem Braynid Linux - Newbie 1 03-26-2007 03:20 AM
NAT problem Baco Linux - Networking 7 01-28-2005 03:11 PM
Susefirewall2 Nat Problem / nat 1:1 trubi Linux - Distributions 0 07-20-2004 05:50 AM
NAT problem Comatose51 Linux - Networking 1 06-23-2003 10:41 PM
What's the difference between Linux-NAT and Sygate-NAT? yuzuohong Linux - Networking 0 08-07-2002 04:07 AM

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

All times are GMT -5. The time now is 07:29 AM.

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