hi,
does anyone know how to setup a port# to each PC of my home network? say 192.168.1.1 is my gateway,, 192.168.1.2 is my linux machine. and my public ip is 1.2.3.4 ... how do i make my 192.168.1.2 a port#(ex: port# 10) so when i ssh from outside my home network, i can do something like "1.2.3.4:10" ?


thanks very much

Its called port forwarding or NAT and the implemention depends on what type of router you have. If your router is a linux router you can use iptables:

#!/bin/sh
iptables -t nat -F
iptables -t filter -F
iptables -t nat -I PREROUTING -i eth0 -d 1.2.3.4 -p tcp --dport 10 -j DNAT --to-destination 192.168.1.2:10
iptables -t nat -A PREROUTING -d 1.2.3.4 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.1.0/255.255.255.0 -j SNAT --to-source 1.2.3.4

If you have a netgear, linksys, etc firewall then you should be able to set up forward rules through the GUI on the router @ http://192.168.1.1

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.