I would like to set a container use the vpn for only network interface.

I have used the pptpsetup and pon make a pptp connection works, and got a ppp0 interface.

Now, I want all internet connection in the systemd-nspawn container go through the ppp0 .

How can I make it work?

systemd-nspawn --network-interface=ppp0

ppp0 will disappear from the host namespace. You can't share one IP address with a container and not your other IP addresses. (Apart from doing NAT).

It looks like this might require a very recent kernel though. http://www.spinics.net/lists/netdev/msg339236.html

OR (machine is created after ppp0):

systemd-nspawn --private-network

ip link set dev ppp0 netns $PID

where $PID is the pid in the host namespace of a process in container, obtained using

P=$(machinectl $MACHINE_NAME show --property=Leader)

and $MACHINE_NAME is the value passed to the -M option of systemd-nspawn

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.