Differences

This shows you the differences between two versions of the page.

Link to this comparison view

access_vm [2017/01/25 00:54] (current)
imcsk8 created
Line 1: Line 1:
 +====== Allow Remote Access to Virtual Machine with Iptables ======
  
 +**To allow remote access to VM in the same LAN**\\
 +Enable ip forwarding:​\\
 +<​code>​
 +# echo 1 > /​proc/​sys/​net/​ipv4/​ip_forward
 +</​code>​
 +\\
 +To make it permanent:​\\
 +<​code>​
 +# echo "​net.ipv4.ip_forward=1"​ >> /​etc/​sysctl.conf
 +</​code>​
 +\\
 +To allow external connections to a VM port:\\
 +Open ssh port:
 +<​code>​
 +# iptables -I  INPUT -i virbr0 -p tcp -m tcp --dport 22 -j ACCEPT
 +</​code>​
 +\\
 +In the remote host (that is on the same LAN) where the VM network is
 +192.168.100.0/​255.255.255.0 and the VM host is: 192.168.1.1
 +<​code>​
 +# route add -net 192.168.100.0/​24 gw 192.168.1.1
 +</​code>​
 +\\
 +And that's it!! be happier than me 'cause i always forget about this.