D
D
den199482017-09-02 00:32:50
Computer networks
den19948, 2017-09-02 00:32:50

How to set up a bridge between Ububntu and LXC?

There is a machine with ubuntu 16, tell me how to set up a network bridge on it, so that lxc docks have a static ip and you can connect to them from outside via ssh.
On ubuntu there are such network interfaces: io, lxcbr0, enp4s3, enp2s0, br0
On Lxc centos eth0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
krosh, 2017-09-04
@krosh

Let's assume that you have an internal network for containers 192.168.0.0.24 via lxcbr0 and it is configured (pings go between the host and containers).

iptables -t nat -A PREROUTING -p tcp -m tcp --dport 22 -j DNAT --to-destination 192.168.0.10:22
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 ! -d 192.168.0.0/24 -o eno1 -j SNAT --to-source 11.22.33.44
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -d 192.168.0.0/24 -j ACCEPT

11.22.33.44 - external host address.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question