Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
07-16-2007, 03:29 AM
|
#1
|
LQ Newbie
Registered: Jul 2006
Posts: 3
Rep:
|
How to configure Iptables with PORT forwarding
Hi
i am new in linux.i Want to share internet and port forwarding. what rules should i add to iptables
Thanks
Gurdeep
Last edited by gurdeep.singh; 07-16-2007 at 04:49 AM.
|
|
|
07-16-2007, 06:26 AM
|
#2
|
LQ Newbie
Registered: May 2005
Location: India
Distribution: redhat,suse,freebsd,mandrake.fedora
Posts: 6
Rep:
|
For Port Forwading
Edit the file /etc/sysctl.conf
and set the value to
net.ipv4.ip_forward = 0
to 1
net.ipv4.ip_forward = 1
And if your using the static ipaddress for Internet
then under the postrouting rule define a rule.
if you use dial up for internet then use the Masquerade rule.
|
|
|
07-16-2007, 02:07 PM
|
#3
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
Quote:
Originally Posted by satishssquid
And if your using the static ipaddress for Internet
then under the postrouting rule define a rule.
if you use dial up for internet then use the Masquerade rule.
|
To add to this: Here's what those commands actually look like:
Code:
iptables -t nat -A POSTROUTING -o eth0 -j SNAT \
--to-source 1.2.3.4
Code:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
These assume eth0 is the name of your external interface, and 1.2.3.4 is the static IP it has. As you can see, the MASQUERADE target doesn't need a static IP, which makes it perfect for dynamic connections, but it will work fine regardless.
|
|
|
07-16-2007, 11:11 PM
|
#4
|
LQ Newbie
Registered: Jul 2006
Posts: 3
Original Poster
Rep:
|
Port forwarding rules
Hi
thanks to all. i am using static ip address. these rules working for internet sharing, but how can i forward vnc request on static ip to my local lan computer.
Thanks
|
|
|
07-18-2007, 02:00 PM
|
#5
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
Quote:
Originally Posted by gurdeep.singh
Hi
thanks to all. i am using static ip address. these rules working for internet sharing, but how can i forward vnc request on static ip to my local lan computer.
Thanks
|
It would go like:
Code:
iptables -t nat -A PREROUTING -p TCP -i eth0 --dport XXX \
-j DNAT --to-destination 192.168.123.123
Replace XXX with whatever port or port range VNC uses.
|
|
|
07-20-2007, 07:05 AM
|
#6
|
LQ Newbie
Registered: Jul 2006
Posts: 3
Original Poster
Rep:
|
Not working
Hi
Dear Friends this rule is not working when i attempt to connect by VNC from Remote network. it gives me error Connection Refused
any other rules
Thanks
Gurdeep Singh
|
|
|
07-24-2007, 12:12 PM
|
#7
|
Member
Registered: Apr 2006
Location: Sweden
Distribution: CentOS, RHEL, SourceMage, OpenBSD
Posts: 40
Rep:
|
Connection refused indicates that the connection is not DROPped by the firewall but that it is rejected. This can be because there is some kind of REJECT rule in the firewall or perhaps more likely that the VNC server is not running (at least not on that port).
Also, you should know that using VNC over a insecure network can be risky since most implementations doesn't use encryption. A more secure way to use VNC is to use it over an SSH tunnel:
http://en.wikipedia.org/wiki/Ssh_tunnel
|
|
|
All times are GMT -5. The time now is 02:46 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|