Questions tagged [port-forwarding]

port-forwarding on firewall or via SSH

Port-forwarding can mean generically forwarding traffic from one port to another from your firewall. It is also used to define an SSH configuration option used to bypass firewall restrictions.

1418 questions
145
votes
8 answers

How can I port forward with iptables?

I want connections coming in on ppp0 on port 8001 to be routed to 192.168.1.200 on eth0 on port 8080. I've got these two rules -A PREROUTING -p tcp -m tcp --dport 8001 -j DNAT --to-destination 192.168.1.200:8080 -A FORWARD -m state -p tcp -d…
Stu
  • 2,198
  • 2
  • 16
  • 23
107
votes
2 answers

How to do the port forwarding from one ip to another ip in same network?

I would like do some NAT in iptables. So that, all the packets coming to 192.168.12.87 and port 80 will be forwarded to 192.168.12.77 port 80. How to do this with iptables? Or Any other ways to achieve the same?
sat
  • 1,273
  • 4
  • 13
  • 14
63
votes
12 answers

Loopback to forwarded Public IP address from local network - Hairpin NAT

This is a Canonical Question about Hairpin NAT (Loopback NAT). The generic form of this question is: We have a network with clients, a server, and a NAT Router. There is port forwarding on the router to the server so some of it's services are…
adopilot
  • 1,521
  • 6
  • 25
  • 41
60
votes
5 answers

iptables port redirect not working for localhost

I want to redirect all traffic from port 443 to the internal port 8080. I'm using this config for iptables: iptables -t nat -I PREROUTING --source 0/0 --destination 0/0 -p tcp \ --dport 443 -j REDIRECT --to-ports 8080 This works for all…
Chris
  • 601
  • 1
  • 6
  • 3
49
votes
3 answers

How to forward port 80 to another port on the samemachine?

How can I forward requests coming in on port 80 to another port on the same linux machine? I used to do this by changing nat.conf, but this machine that I'm using doesn't have NAT. What's the alternative?
Nohsib
  • 591
  • 1
  • 4
  • 3
46
votes
8 answers

Port forwarding on Linux without iptables?

I have a Linux VPS (virtuozzo) server and I need to setup port forwarding, but my hosting provider does not allow iptables-nat kernel modules so iptables -t nat - is not working. I'm looking for other ways how to do it. I know I can forward port…
troex
  • 743
  • 2
  • 7
  • 9
45
votes
6 answers

Forwarding ports to guests in libvirt / KVM

How can I forward ports on a server running libvirt/KVM to specified ports on VM's, when using NAT? For example, the host has a public IP of 1.2.3.4. I want to forward port 80 to 10.0.0.1 and port 22 to 10.0.0.2. I assume I need to add iptables…
steveh7
  • 453
  • 1
  • 5
  • 4
44
votes
7 answers

Forward local port or socket file to remote socket file

Quick question - I run two linux boxes, one my own desktop and the other my VPS. For security reasons on the VPS end I opted for socket connections to MySQL (/var/run/mysqld/mysql.sock). I know I can tunnel like this: ssh -L 3307:127.0.0.1:3306…
user32616
42
votes
2 answers

Can I use ufw to setup a port forward?

Im currently using ufw to enforce some basic firewall rules. Is it possible to also use ufw to do port forwarding? Specifically im wanting to forward incoming traffic to my server (same machine running ufw) on port 80 to port 8080. (http traffic…
tinny
  • 491
  • 2
  • 5
  • 11
40
votes
6 answers

Forward SSH through SSH tunnel

My situation : Me(localhost) -> Server A(ip:100.100.100.100) =>(server B(ip:192.168.25.100),server....) i'm able to SSH into server since it has a true ip if i then want to connect to server b, i would ssh server b with it's…
tom91136
  • 503
  • 1
  • 4
  • 7
36
votes
5 answers

SSH remote port forwarding failed

Follow-Up: It looks like the rapid series of disconnects coinciding with a few months of running each server is probably coincidental and just served to reveal the actual problem. The reason it failed to reconnect is almost certainly due to the…
jstm88
  • 757
  • 2
  • 9
  • 21
28
votes
7 answers

Why can't I access my CouchDB instance externally on Ubuntu 9.04 server?

Update: I got it working now. Jim Zajkowski's answer helped me detect that my /etc/init.d/couchdb reboot calls weren't actually rebooting the instance. After I manually killed the CouchDB processes and started a new instance, it picked up the…
rcampbell
  • 1,035
  • 4
  • 14
  • 24
25
votes
6 answers

Use iptables to forward ipv6 to ipv4?

Currently I have a setup where, due to configuration that would take forever to fix, I have a server that can only be accessed by ipv4. I also, however, have a server that can be accessed by ipv6. I was wondering if I could use iptables to forward…
Eli
  • 395
  • 3
  • 7
  • 15
24
votes
4 answers

Undoing port forwarding

I need all requests to port 80 to be forwarded to 8020. I Googled it and I got: iptables -t nat -I PREROUTING --source 0/0 --destination 0/0 -p tcp --dport 80 -j REDIRECT --to-ports 8020 Now in the future if I have to undo it what do I do (apart…
raj
  • 371
  • 1
  • 4
  • 9
23
votes
1 answer

SSH Reverse Port Forwarding with PuTTy - how to specify bind address

Using Putty, I have set up a reverse proxy which allows me to connect on port 8080 of the server at server.tld to port 80 of the machine which initiated the SSH connection. The server allows me to connect on localhost:8080 and returns the result of…
Darbio
  • 557
  • 1
  • 5
  • 15
1
2 3
94 95