How to redirect to FTP server in LAN?

Discussion in 'Server Operation' started by homi, Oct 12, 2017.

  1. homi

    homi New Member

    I have 2 servers Ubuntu. One is inet provider with static public IP adress (ext. 80.122.45.122, int 192.168.1.50). And second is FTP server (and backup server etc.), in the same LAN, with IP static 198.168.1.51. How to redirect to my FTP server from outside of LAN ? FTP server is 192.168.1.51, port 21. Thanks.
     
  2. You can use iptables to redirect traffic,
    Use following commands for iptables

    Code:
    iptables -t nat -A PREROUTING -p tcp --dport 21 -j DNAT --to 192.168.1.51:21
    
    
    iptables -A FORWARD -d 192.168.1.51 -p tcp --dport 21 -j ACCEPT
    
    
    sysctl net.ipv4.ip_forward=1

    the first line puts a iptables rule to change the destination address and port.

    the second line allows this redirected traffic to be forwarded.

    the third line enables traffic forwarding in the kernel.
     
  3. ahrasis

    ahrasis Active Member

    By "lan" do you mean behind a router?Because if it is, port forwarding (TCP) to your ftp pc ip in your router settings would suffice.
     

Share This Page