Re: open port to specific ip address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 10 November 2003 10:55 am, Lohan Spies wrote:

> Hi All,
>
> I need to know how will i open a specific port to a external ip mapping!
>
> I need to specify a internal_ip:port on my internal network, and then if
> someone connects to internal_ip:port it must redirect them to
> external_ip with no cgi scripting and no authentication support!
>
> How will i do this?

ip addr add dev eth1 internal_ip
iptables -A PREROUTING -t nat -d internal_ip -p tcp --dport port -j DNAT --to 
external_ip
iptables -A FORWARD -d external_ip -p tcp --dport port -j ACCEPT

I'm assuming TCP here since you didn't specify - if you need UDP instead 
simply replace in both lines.   Also I've assumed eth1 is your internal 
interface - change if needed.

Antony.

-- 

It's a natural impulse to shape the random events we live through into 
coherent narrative, otherwise our lives would feel like experimental theatre 
or abstract painting, which would be a complete bloody nightmare.

 - Pete McCarthy, The Road to McCarthy
                                                     Please reply to the list;
                                                           please don't CC me.


[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux