Skip to content

Instantly share code, notes, and snippets.

@DManavi
Created March 9, 2019 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DManavi/c93233b5362f84705cd91b877ef11a39 to your computer and use it in GitHub Desktop.
Save DManavi/c93233b5362f84705cd91b877ef11a39 to your computer and use it in GitHub Desktop.
NAT LXC Without forwarding and IP tables

Run these commands to proxy any TCP/UDP connection from host to your container

lxc config device add {your-container-name} {a-simple-name-for-device} proxy listen={host-protocol}:{host-ip}:{host-port} connect={container-protocol}:{container-ip}:{container-port}

Example values

{your-container-name} = web-server {a-simple-name-for-device} = http-80

{host-protocol} = tcp {host-ip} = 10.0.0.1 {host-port} = 80

{container-protocol} = tcp {container-ip} = localhost {container-port} = 8080

@DManavi
Copy link
Author

DManavi commented Mar 9, 2019

@ham3dz please take a look. I found this magic code helpful!

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