Skip to content

Instantly share code, notes, and snippets.

@teopeurt
Created March 17, 2016 07:49
Show Gist options
  • Save teopeurt/acd7e94715e8d6164050 to your computer and use it in GitHub Desktop.
Save teopeurt/acd7e94715e8d6164050 to your computer and use it in GitHub Desktop.
#!/bin/bash
CONTAINER=$2
HOSTPORT=$1
CONTAINERPORT=$3
container_ip=$(lxc info $CONTAINER | grep 'eth0' | head -n1 | awk '{print $3}')
iptables -t nat -A PREROUTING -p tcp -i eth0 --dport $HOSTPORT -j DNAT \
--to-destination $container_ip:$CONTAINERPORT
@teopeurt
Copy link
Author

teopeurt commented Jul 11, 2019

sudo sh lxdip.sh public_port container_name container_port

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment