LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   masqueraded and got internet connection, no remote access to gateway! (https://www.linuxquestions.org/questions/linux-networking-3/masqueraded-and-got-internet-connection-no-remote-access-to-gateway-461073/)

imagineers7 07-04-2006 11:28 PM

masqueraded and got internet connection, no remote access to gateway!
 
Hi everyone,

I tried reading some threads but did not found solution.
This is because of my lower understanding with iptables and
I wanted to share a connection in my home lan using iptables forwarding but some how packets do get forwarded ,I can use Internet connection on all my machines but I cant access the machine (gateway) remotely. I think I am directly forwording the packets destined to the machine itself and want a way to return them to the machine. RETURN has something to do with this and I cant figure it out. Can some body help me.

Quote:

[root@firebird fire]# for nameserver in `grep nameserver /etc/resolv.conf | gawk -F" " '{print $2}'`; do iptables -t nat -A PREROUTING -d 192.168.111 -j DNAT --to-destination $nameserver; echo -e " Name server defined at $nameserver"; done;
Name server defined at x.x.x.x
Name server defined at x.x.x.x
[root@firebird fire]# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
Above are the commands that I fire up to get connected to the Internet but after that I just cant access the machine by any other means (SSH , webmin)

Where I am going wrong?


Thanks in advance


Aniruddha

blackhole54 07-06-2006 04:10 AM

If your LAN is connected to eth0, and eth1 is your Internet connection, your POSTROUTING command looks fine. (Use SNAT instead of MASQUERADE if you have a static Internet IP address.) This should not interfere with your LAN operation and you should not need any additional commands to make it work.

If you are having trouble (for example) ssh'ing into this machine from another box on your LAN, your problem is probably in your netfilter INPUT chain, or possibly OUTPUT chain. If you can't access this machine from the Internet, your problem could, again, be in the INPUT or OUTPUT chain. But if you have a router (or NAT device) between your gateway machine and the Internet, you will need to set it up for port forwarding before you can access your box from the Internet.

imagineers7 07-06-2006 11:28 PM

Hi BlackHole54,

Thanks for your reply,

I will check it out with snat and post what happens next.



Thanks again



Aniruddha


All times are GMT -5. The time now is 01:41 PM.