60
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 (LOCAL PORT TO ...
31
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 ...
25
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 ...
25
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
...
24
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 ...
23
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 ...
18
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, ...
18
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.
17
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 ...
15
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 ...
15
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 ...
13
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 ...
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 ...
11
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 ...
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
11
votes
11
votes
Accepted
How to add local forward setting to my ssh config file?
The syntax of the ssh_config file was correct - so the error had to be somewhere else. The command line which worked was:
ssh 12.34.56.78 -L 8888:localhost:8000
but in the LocalForward directive, you ...
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 ...
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/...
9
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, ...
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 ...
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:/...
8
votes
Accepted
How to port forward only on a single host IP address
A firewalld zone can be specified either by interface or by source address, but you want to filter by destination address. You'll need a rich rule to handle this particular situation.
Such a rich ...
8
votes
Accepted
How to redirect port 80 to 8080 while keeping 8080 closed to the Internet?
This schematic should help you understand how packet handling is done:
The filter/INPUT rules see only packets after they were NATed in nat/PREROUTING, so by default can't tell the difference between ...
8
votes
Accepted
Double port forwarding kubernetes + docker
I think there are two possible solutions that may help in your case:
You can add the --address argument to the kubectl port-forward command with the IP address of the container running this command. ...
7
votes
Port forwarding test possible within LAN? Mikrotik Router
Mikrotik RouterOS based on the Linux kernel and has inherited most of the conceptions of networking.
So, I'll describe the setup of the port forwarding in the Mikrotik routers. And I'll try to ...
7
votes
Is there a speed and performance difference between VPNs (L2TP, etc.) vs. port forwarding?
Port forwarding would be quicker, but it would be less secure, in the sense that there is no confidentiality, or integrity. If you don't care then it is not a problem. Any VPN or tunnelling will add ...
7
votes
Accepted
Port forwarding with wireguard
Since you're using UFW, first make sure the UFW rule for port 56000 that you added is not a regular input rule, but instead a "route" (aka forwarding) rule, like this (assuming it's for a ...
6
votes
lxd container: port forwarding like docker
Four years later, the prediction given in this answer was fortunately too pesimisitc. Port forwarding has been implementented in LXD in the meantime as is documented here.
To forward port 80 on the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
port-forwarding × 1427iptables × 364
ssh × 199
nat × 176
linux × 173
networking × 134
router × 109
firewall × 103
port × 103
ssh-tunnel × 103
ubuntu × 90
routing × 60
vpn × 52
linux-networking × 50
openvpn × 47
apache-2.2 × 46
proxy × 40
domain-name-system × 39
cisco × 38
nginx × 37
docker × 36
ip × 35
reverse-proxy × 33
windows × 32
amazon-ec2 × 28