51
votes
Forward local port or socket file to remote socket file
Altough in the time, when the question was asked, it was really impossible,
but it is possible nowadays.
You can to both: UNIX=>TCP and UNIX=>UNIX forwarding.
For example:
ssh \
-R/var/run/mysql....
- 631
32
votes
Accepted
How to ssh to a server which I can not directly reach?
You can use the following command to set up an SSH tunnel from the remote server to your local machine:
$ ssh -f -N -R 1234:localhost:22 user@your_machine_ip
When the tunnel is set up, you can ...
- 36.1k
23
votes
How to forward port 80 to another port on the samemachine?
Just found myself in this question and couldn't find an easy way. Don't want to install Nginx in my machine to do this simple port forwarding.
Rinetd didn't work for me, no working package for my ...
- 331
22
votes
Accepted
nginx proxy_pass using subfolder
Since you tagged this as a reverse proxy question, I assume you mean that you want to proxy the request so that user only sees http://aaa.bbb.ccc.ddd/app2 URL in her browser.
You can change your ...
- 35.6k
19
votes
QEMU multiple port forwarding
Got it to work:
with -net:
qemu-system-i386 -net nic,model=rtl8139 \
-net user,hostfwd=tcp::3389-:3389,hostfwd=tcp::443-:443,hostfwd=tcp::992-:992 \
-m 512M -localtime -cpu core2duo,+nx -smp 2 -...
- 371
19
votes
Accepted
How to temporarily disable local forwards
There is ClearAllForwardings option in ssh_config, which does exactly what you need:
ClearAllForwardings
Specifies that all local, remote, and dynamic port forwardings specified in the ...
- 9,355
18
votes
Accepted
Running a websocket server and a http server on the same server
A terribly written question, but the term I was looking for was reverse proxy.
Basically, just like how nginx can forward different request to several instances of the web app based on the path or ...
- 412
16
votes
Forward SSH through SSH tunnel
As of OpenSSH 7.3 (late 2016) the easiest way is the ProxyJump setting. In your ~/.ssh/config:
Host B
ProxyJump A
Or on the command line, -J B.
- 291
15
votes
How to add local forward setting to my ssh config file?
I think, you have differently defined command and config. In command, you are using localhost and in config, IP address (12.34.56.78). This should works for you:
Host myhost
User myuser
...
- 251
14
votes
Can't SSH into a Vagrant Virtual Machine
It's old but as there is no answer, I'll provide one.
Command:
vagrant ssh
Is the equivalent of
ssh vagrant@localhost -p 2222 -i .vagrant/machines/default/virtualbox/private_key
This is default ...
- 141
14
votes
Accepted
SSH: What's the difference between -L and -R?
It's right there, in the man page:
-L
Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix socket, on the ...
- 21.3k
13
votes
Windows 7 with internal port redirection, is it possible?
Yes, windows does have a iptables equivalent, it is via the tool netsh and the portproxy interface.
The command to do what you want would be
netsh interface portproxy add v4tov4 listenaddress=...
- 1,455
12
votes
How can I port forward with iptables?
The accepted solution works when the destination host and the gateway are on the same subnet (like is in your case, both are on eth0 192.168.1.0/24).
Below is a generic solution for when the gateway, ...
- 1,596
12
votes
Accepted
Iptables forward all traffic to a specified port, to another device
This rule will forward 80 port to 192.168.42.10
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.42.10:80
but this is not enough
If you want to get back traffic then ...
- 1,608
12
votes
Accepted
Accessing to a remote PostgreSQL server using port forwarding to another machine
This command:
ssh -L 54320:Server_A:5432 user@Server_B
looks good, but then when doing this:
psql -p 54320 -d db_name -U user
the ssh tunnel is not used, because by default on Unix, psql connects ...
- 2,860
12
votes
Accepted
Set up public ip on server
Presenting a service to the Internet definitely should not be done unless you know what you're doing. Fortunately it's mostly a matter of not being naïve, but you definitely should have passed a ...
- 4,961
11
votes
Accepted
iptables port forwarding to server with different port
Damn it. I fixed it like a min after posting this. Solution:
echo 1 > /proc/sys/net/ipv4/ip_forward
- 169
11
votes
10
votes
Can I use ufw to setup a port forward?
Since ufw 0.34 ufw supports forward rules.
example: sudo ufw route allow in on eth0 out on eth1 to 10.0.0.0/8 port 8080 from 192.168.0.0/16 port 80
You also need to make sure you have the ...
- 249
10
votes
Accepted
Port forward with iptables
When you are trying to reach localhost, your source address is 127.0.0.1, as is your destination address. So, packet looks something like this:
| SRC | DST |
| 127.0.0.1 | 127.0.0.1 ...
- 5,247
10
votes
Accepted
ssh remote port forwarding: connection refused
tcp 0 0 127.0.0.1:1234 0.0.0.0:* LISTEN 14460/1
Problem can be very well seen in the output of netstat.
Your remote machine is listening on 127.0.0.1:1234, which is ...
- 615
9
votes
Forward local port or socket file to remote socket file
No more socat is needed since ssh 6.7. You can forward unix domain sockets directly like:
ssh -nNT -L $(pwd)/docker.sock:/var/run/docker.sock user@someremote
More info: https://medium.com/@dperny/...
- 335
9
votes
How can I port forward with iptables?
I have created the following bash script for doing this on my linux router. It automatically infers the WAN IP and confirms your selections before proceeding.
#!/bin/bash
# decide which action to ...
- 91
9
votes
Accepted
RDP equivalent to SSH port forwarding?
No, it is not possible with RDP.
You can install an SSH server on windows and continue to use SSH.
Alternatively, you can use netsh to do TCP forwarding as described in this answer on SO:
netsh ...
- 21.3k
8
votes
Forwarding ports to guests in libvirt / KVM
A more "official"[1] way to do this is to create a hook script as described at the libvirt website:
http://wiki.libvirt.org/page/Networking#Forwarding_Incoming_Connections
... basically this script ...
- 311
8
votes
Forward SSH through SSH tunnel
according to the ssh man page, ProxyCommand is the correct method
the syntax being:
ProxyCommand ssh -W %h:%p user@jumphost 2> /dev/null
- 81
8
votes
Getting 'ERR_CONNECTION_REFUSED' when trying to browse port mapped to Docker container
Finally figured out how to make this work!
I'm running Docker on MacOS and using 'Docker QuickStart Terminal'.
Turns out, navigating to 'localhost', '127.0.0.1', etc. was wrong, because it looks ...
- 557
8
votes
Accepted
Using iptables port redirection with docker
A possible modification to the iptables rules is to remove both and replace with:
iptables -t nat -A PREROUTING -p tcp -m tcp -i eth0 --dport 80 -j REDIRECT --to-ports 8080
This will ensure that, ...
- 373
8
votes
Accepted
host port forward with qemu through libvirt in user-mode networking
the missing part from your configuration is described here: https://www.linux-kvm.org/page/Networking. You have to add another netdev with new address like so:
<domain type='kvm' xmlns:qemu='http:/...
- 96
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
port-forwarding × 1387iptables × 355
ssh × 191
nat × 168
linux × 163
networking × 124
router × 106
ssh-tunnel × 102
port × 100
firewall × 97
ubuntu × 80
routing × 57
vpn × 49
openvpn × 48
apache-2.2 × 46
linux-networking × 46
proxy × 40
domain-name-system × 39
nginx × 38
cisco × 38
reverse-proxy × 34
docker × 33
ip × 33
windows × 30
amazon-ec2 × 28