Thursday, October 22, 2015

Configure local ubuntu to be accessed remotely

LAN

1, configure ssh.

  • we need ssh server to share our machine with others. ssh is usually installed in linux distributions, however , ssh server is not installed. so first , we need to install a ssh server.  "sudo apt-get install openssh-server"  
  • start ssh server with command "sudo /etc/init.d/ssh start" check if it's started using command "ps -e  | grep sshd"
  • set the port which ssh server will listen for. "vim /etc/ssh/sshd_config" there is a line starting with "Port port_number", we can change this port_number to the port we want to listen for.

2, configure firewall: iptables

  • add some rules to accept packages from other machine. "sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT " 
  • save set (method 1)(make iptables rules persistent): 
    • "iptables-save > /etc/iptables.rules" : save set in file iptables.rules
    • edit a bash file in /etc/network/if-pre-up.d/iptables.sh                                   
      • #! /bin/bash
      • iptables-restore < /etc/iptables.rules"
  • save rules permant (method 2) 
    • sudo apt-get install iptables-persistent
    • service iptables-persistent start

WAN


  1. if your server is in a LAN, and you want to access a server in the LAN from outside, then find the router of the LAN, and configure the router. Set the router to forward to forward connections to port 4015(set above) to your internal IP address.

No comments:

Post a Comment