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 12-12-2007, 02:39 AM   #1
pengusaha
LQ Newbie
 
Registered: Dec 2007
Distribution: Redhat FC6
Posts: 11

Rep: Reputation: 0
fc6---nat doesnt work :(


alo..ive got small problem
my linux server cant act as nat to client...

linux = eth0 to lan
ppp0 to internet dialup modem
eth0 = 192.168.0.5

client = xp can ping to linux..and can sharing file through samba..
gateway have set to 192.168.0.5

linux can going internet...ihv tried traceroute www.google.com
when connected to internet....

why is my client cant connnect to internet through linux ?

ive done

uda echo 1 > /proc/sys/net/ipv4/ip_forward

/sbin/iptables --flush
/sbin/iptables --table nat --flush
/sbin/iptables --delete-chain
/sbin/iptables --table nat --delete-chain
/sbin/iptables -t nat -A POSTROUTING -d 0/0 -o ppp0 -j MASQUERADE

lsmod | grep ip
everything about masquerade are up

tq master...
 
Old 12-12-2007, 07:54 PM   #2
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
The documentation on iptables is not especially clear on this point, but you must not only do the NAT, but must also actually put in a FORWARD rule (unless your iptables is set to forward everything, which is not a good idea). Check your forwarding rules with
Quote:
# iptables -nvL FORWARD
to see what the default policy is, and to see if there are any rules in place already.

A correct ruleset for this situation is
Code:
-P FORWARD DROP
-A FORWARD -i eth0 -j ACCEPT
-A FORWARD -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
This will pass all outbound TCP connections from behind the firewall, and allow the returns. It will not allow any UDP or ICMP traffic through the firewall. (Separate rules in the INPUT chain can determine what is allowed to terminate on the firewall machine, where you may have public services available either via TCP or UDP.)

Finally, make sure that your client machine (behind the firewall) has its Default Gateway set to the correct address. You can find this by following the chain
Quote:
Control Panel\ Network Connections\ Local Area Connection\ Properties\ Internet Protocol\ Properties\ Advanced\ Default Gateway
. The address to use is the IP address of eth0 on your firewall, since that is where any packet that is headed for the Internet should go first.
 
Old 12-12-2007, 10:00 PM   #3
pengusaha
LQ Newbie
 
Registered: Dec 2007
Distribution: Redhat FC6
Posts: 11

Original Poster
Rep: Reputation: 0
tq very much sir...ive done

/sbin/iptables --flush
/sbin/iptables --table nat --flush
/sbin/iptables --delete-chain
/sbin/iptables --table nat --delete-chain

and

/sbin/iptables -P FORWARD DROP
/sbin/iptables -A FORWARD -i eth0 -j ACCEPT
/sbin/iptables -A FORWARD -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT


/sbin/iptables -nvL FORWARD

Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- eth0 * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- ppp0 * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED




client xp
Control Panel\ Network Connections\ Local Area Connection\ Properties\ Internet Protocol\ Properties\ Advanced\ Default Gateway

gateway = ip linux (server which connect to internet via dialup ppp0


but... my client cant go to internet

what other else ?
 
Old 12-13-2007, 12:32 AM   #4
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
It is still necessary to have the MASQERADE rule in the nat table. When you flushed everything, you removed that rule as well. Without both the MASQUERADE rule and the FORWARD rules, your client will not be able to connect, as you have noted.

It appears that you should do this:
Code:
/sbin/iptables --flush
/sbin/iptables --table nat --flush
/sbin/iptables --delete-chain
/sbin/iptables --table nat --delete-chain
/sbin/iptables -t nat -A POSTROUTING -d 0/0 -o ppp0 -j MASQUERADE
and then put in the forwarding rules:
Code:
/sbin/iptables -P FORWARD DROP
/sbin/iptables -A FORWARD -i eth0 -j ACCEPT
/sbin/iptables -A FORWARD -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT
 
Old 12-13-2007, 04:48 AM   #5
pengusaha
LQ Newbie
 
Registered: Dec 2007
Distribution: Redhat FC6
Posts: 11

Original Poster
Rep: Reputation: 0
tq very much master...but still no hope after this command

/sbin/iptables --flush
/sbin/iptables --table nat --flush
/sbin/iptables --delete-chain
/sbin/iptables --table nat --delete-chain
/sbin/iptables -t nat -A POSTROUTING -d 0/0 -o ppp0 -j MASQUERADE

/sbin/iptables -P FORWARD DROP
/sbin/iptables -A FORWARD -i eth0 -j ACCEPT
/sbin/iptables -A FORWARD -i ppp0 -m state --state ESTABLISHED,RELATED -j ACCEPT


this linux box can connect to the internet..but client (xp) still
cant go to internet....
 
Old 12-14-2007, 09:01 AM   #6
pengusaha
LQ Newbie
 
Registered: Dec 2007
Distribution: Redhat FC6
Posts: 11

Original Poster
Rep: Reputation: 0
can any 1 help me with this ?
 
Old 12-15-2007, 05:37 PM   #7
dkm999
Member
 
Registered: Nov 2006
Location: Seattle, WA
Distribution: Fedora
Posts: 407

Rep: Reputation: 35
There is something going on here that is not yet apparent. To get a better reading on this, I recommend that you add one more rule to your FORWARD chain, which will log any packets that the firewall machine blocks:
Code:
iptables -A FORWARD -j LOG --log-prefix FWD:
Put this at the end of the list of commands that add rules to the FORWARD chain. This additional rule will write an entry into the syslog (/var/log/messages) for each packet that it blocks. Then try to get your XP machine to access the Internet, and then post the resulting messages that begin with FWD: here, along with the output of the command iptables -nvL FORWARD. That may tell us which of several problems is occurring. My current guesses are
1. For reasons unknown, the XP machine is sending its packets destined for the Internet somewhere else.
2. The firewall might be blocking the return packets, rather than sending them back onto your local network.
3. The PPP connection might be broken in some way that we have not discovered.
 
Old 12-16-2007, 02:22 AM   #8
pengusaha
LQ Newbie
 
Registered: Dec 2007
Distribution: Redhat FC6
Posts: 11

Original Poster
Rep: Reputation: 0
thx very much master.....problem solved
after i set my client (xp) dns to isp_dns

its all my mistake....tq very much....


this command is good for debugging masq..
iptables -A FORWARD -j LOG --log-prefix FWD:

but after i ran this command i dont see any log
in tail -f /var/log/messages

tq very much master....
 
  


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
Sound doesn't work, FC6 doesnt find AC97 on motherboard. Mercantez Linux - Newbie 10 04-30-2007 12:04 PM
FC6 doesnt BOOT UP kariukidw Fedora 4 01-05-2007 12:57 PM
Why doesnt my USB mouse doesnt work? barkha Linux - Hardware 2 08-16-2005 11:31 AM
NAT doesnt work for me this time.. stradivarius Linux - Networking 0 04-17-2004 12:00 PM
NAT doesnt work for me this time.. stradivarius Linux - Networking 0 04-17-2004 11:50 AM

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

All times are GMT -5. The time now is 04:15 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