lxc container has internet access, how to access internet from host

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















I have a requirement that networking has to be managed by lxc container, so the Ethernet interface(eth0, which is the source of internet) is assigned to container.



I am able to ping "8.8.8.8" from the container.



To access the internet from host, created veth type network configuration for the container.



lxc.net.3.type = veth



lxc.net.3.flags = up



lxc.net.3.veth.pair = lxc0



lxc.net.3.hwaddr = 4a:49:43:49:79:bf



lxc.net.3.ipv4.address = 192.168.1.1/24 192.168.1.255



then forwarded the packets from eth1 to eth0 and eth0 to eth1 as mentioned in
https://superuser.com/questions/938805/how-forward-packets-from-network-interface-to-another



but the "ping -I lxc0 8.8.8.8" is not working from the host.



tcpdump on eth1 interface(tcpdump -i eth1) shows that the ping request is received in the container.



tcpdump shows the output as



ARP, Request who-has 8.8.8.8 tell 192.168.1.2(192.168.1.2 is lxc0's ip in host)



eth0 is the default gateway inside the container.










share|improve this question
























  • iptables doesn't route. So whatever you mean by "routed ... using iptables" you'll have to edit your question to clarify what you did (adding missing IPs, routes, iptables rules)

    – A.B
    Jan 15 at 22:39












  • @A.B edited the question

    – enthu
    Jan 16 at 19:55












  • There are still missing informations: what is the IP assigned on host0? it can't be XX.XX.XX.XX it should be 192.168.1.Y. I'll give clues for you to find the issue else I fear I'll find there are still missing informations: the container has to NAT the host: you need a MASQUERADE rule on the container. the host needs a gateway: its default route must be via 192.168.0.1 or you get those strange ARPs

    – A.B
    Jan 16 at 20:46












  • @A.B ip on host0 is 169.254.99.31 and ip for lxc0 is 169.254.99.30, somehow its not taking the 192.168.0.1 for lxc0 i just now tried superuser.com/questions/938805/…, still it does not work default route on host is 169.254.99.31

    – enthu
    Jan 16 at 20:50












  • Well fix your host's host0 to be in the 192.168.0.0/24 range (I don't know what's the problem), and fix the container in LXC by not configuring at all lxc0 by the container's OS: LXC already configured it. don't even declare an lxc0 interface. There are too many small issues at once. Try to solve them then rework your question to have all those informations ready

    – A.B
    Jan 16 at 20:57
















0















I have a requirement that networking has to be managed by lxc container, so the Ethernet interface(eth0, which is the source of internet) is assigned to container.



I am able to ping "8.8.8.8" from the container.



To access the internet from host, created veth type network configuration for the container.



lxc.net.3.type = veth



lxc.net.3.flags = up



lxc.net.3.veth.pair = lxc0



lxc.net.3.hwaddr = 4a:49:43:49:79:bf



lxc.net.3.ipv4.address = 192.168.1.1/24 192.168.1.255



then forwarded the packets from eth1 to eth0 and eth0 to eth1 as mentioned in
https://superuser.com/questions/938805/how-forward-packets-from-network-interface-to-another



but the "ping -I lxc0 8.8.8.8" is not working from the host.



tcpdump on eth1 interface(tcpdump -i eth1) shows that the ping request is received in the container.



tcpdump shows the output as



ARP, Request who-has 8.8.8.8 tell 192.168.1.2(192.168.1.2 is lxc0's ip in host)



eth0 is the default gateway inside the container.










share|improve this question
























  • iptables doesn't route. So whatever you mean by "routed ... using iptables" you'll have to edit your question to clarify what you did (adding missing IPs, routes, iptables rules)

    – A.B
    Jan 15 at 22:39












  • @A.B edited the question

    – enthu
    Jan 16 at 19:55












  • There are still missing informations: what is the IP assigned on host0? it can't be XX.XX.XX.XX it should be 192.168.1.Y. I'll give clues for you to find the issue else I fear I'll find there are still missing informations: the container has to NAT the host: you need a MASQUERADE rule on the container. the host needs a gateway: its default route must be via 192.168.0.1 or you get those strange ARPs

    – A.B
    Jan 16 at 20:46












  • @A.B ip on host0 is 169.254.99.31 and ip for lxc0 is 169.254.99.30, somehow its not taking the 192.168.0.1 for lxc0 i just now tried superuser.com/questions/938805/…, still it does not work default route on host is 169.254.99.31

    – enthu
    Jan 16 at 20:50












  • Well fix your host's host0 to be in the 192.168.0.0/24 range (I don't know what's the problem), and fix the container in LXC by not configuring at all lxc0 by the container's OS: LXC already configured it. don't even declare an lxc0 interface. There are too many small issues at once. Try to solve them then rework your question to have all those informations ready

    – A.B
    Jan 16 at 20:57














0












0








0








I have a requirement that networking has to be managed by lxc container, so the Ethernet interface(eth0, which is the source of internet) is assigned to container.



I am able to ping "8.8.8.8" from the container.



To access the internet from host, created veth type network configuration for the container.



lxc.net.3.type = veth



lxc.net.3.flags = up



lxc.net.3.veth.pair = lxc0



lxc.net.3.hwaddr = 4a:49:43:49:79:bf



lxc.net.3.ipv4.address = 192.168.1.1/24 192.168.1.255



then forwarded the packets from eth1 to eth0 and eth0 to eth1 as mentioned in
https://superuser.com/questions/938805/how-forward-packets-from-network-interface-to-another



but the "ping -I lxc0 8.8.8.8" is not working from the host.



tcpdump on eth1 interface(tcpdump -i eth1) shows that the ping request is received in the container.



tcpdump shows the output as



ARP, Request who-has 8.8.8.8 tell 192.168.1.2(192.168.1.2 is lxc0's ip in host)



eth0 is the default gateway inside the container.










share|improve this question
















I have a requirement that networking has to be managed by lxc container, so the Ethernet interface(eth0, which is the source of internet) is assigned to container.



I am able to ping "8.8.8.8" from the container.



To access the internet from host, created veth type network configuration for the container.



lxc.net.3.type = veth



lxc.net.3.flags = up



lxc.net.3.veth.pair = lxc0



lxc.net.3.hwaddr = 4a:49:43:49:79:bf



lxc.net.3.ipv4.address = 192.168.1.1/24 192.168.1.255



then forwarded the packets from eth1 to eth0 and eth0 to eth1 as mentioned in
https://superuser.com/questions/938805/how-forward-packets-from-network-interface-to-another



but the "ping -I lxc0 8.8.8.8" is not working from the host.



tcpdump on eth1 interface(tcpdump -i eth1) shows that the ping request is received in the container.



tcpdump shows the output as



ARP, Request who-has 8.8.8.8 tell 192.168.1.2(192.168.1.2 is lxc0's ip in host)



eth0 is the default gateway inside the container.







linux networking lxc






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 17 at 18:53







enthu

















asked Jan 15 at 21:59









enthuenthu

62




62












  • iptables doesn't route. So whatever you mean by "routed ... using iptables" you'll have to edit your question to clarify what you did (adding missing IPs, routes, iptables rules)

    – A.B
    Jan 15 at 22:39












  • @A.B edited the question

    – enthu
    Jan 16 at 19:55












  • There are still missing informations: what is the IP assigned on host0? it can't be XX.XX.XX.XX it should be 192.168.1.Y. I'll give clues for you to find the issue else I fear I'll find there are still missing informations: the container has to NAT the host: you need a MASQUERADE rule on the container. the host needs a gateway: its default route must be via 192.168.0.1 or you get those strange ARPs

    – A.B
    Jan 16 at 20:46












  • @A.B ip on host0 is 169.254.99.31 and ip for lxc0 is 169.254.99.30, somehow its not taking the 192.168.0.1 for lxc0 i just now tried superuser.com/questions/938805/…, still it does not work default route on host is 169.254.99.31

    – enthu
    Jan 16 at 20:50












  • Well fix your host's host0 to be in the 192.168.0.0/24 range (I don't know what's the problem), and fix the container in LXC by not configuring at all lxc0 by the container's OS: LXC already configured it. don't even declare an lxc0 interface. There are too many small issues at once. Try to solve them then rework your question to have all those informations ready

    – A.B
    Jan 16 at 20:57


















  • iptables doesn't route. So whatever you mean by "routed ... using iptables" you'll have to edit your question to clarify what you did (adding missing IPs, routes, iptables rules)

    – A.B
    Jan 15 at 22:39












  • @A.B edited the question

    – enthu
    Jan 16 at 19:55












  • There are still missing informations: what is the IP assigned on host0? it can't be XX.XX.XX.XX it should be 192.168.1.Y. I'll give clues for you to find the issue else I fear I'll find there are still missing informations: the container has to NAT the host: you need a MASQUERADE rule on the container. the host needs a gateway: its default route must be via 192.168.0.1 or you get those strange ARPs

    – A.B
    Jan 16 at 20:46












  • @A.B ip on host0 is 169.254.99.31 and ip for lxc0 is 169.254.99.30, somehow its not taking the 192.168.0.1 for lxc0 i just now tried superuser.com/questions/938805/…, still it does not work default route on host is 169.254.99.31

    – enthu
    Jan 16 at 20:50












  • Well fix your host's host0 to be in the 192.168.0.0/24 range (I don't know what's the problem), and fix the container in LXC by not configuring at all lxc0 by the container's OS: LXC already configured it. don't even declare an lxc0 interface. There are too many small issues at once. Try to solve them then rework your question to have all those informations ready

    – A.B
    Jan 16 at 20:57

















iptables doesn't route. So whatever you mean by "routed ... using iptables" you'll have to edit your question to clarify what you did (adding missing IPs, routes, iptables rules)

– A.B
Jan 15 at 22:39






iptables doesn't route. So whatever you mean by "routed ... using iptables" you'll have to edit your question to clarify what you did (adding missing IPs, routes, iptables rules)

– A.B
Jan 15 at 22:39














@A.B edited the question

– enthu
Jan 16 at 19:55






@A.B edited the question

– enthu
Jan 16 at 19:55














There are still missing informations: what is the IP assigned on host0? it can't be XX.XX.XX.XX it should be 192.168.1.Y. I'll give clues for you to find the issue else I fear I'll find there are still missing informations: the container has to NAT the host: you need a MASQUERADE rule on the container. the host needs a gateway: its default route must be via 192.168.0.1 or you get those strange ARPs

– A.B
Jan 16 at 20:46






There are still missing informations: what is the IP assigned on host0? it can't be XX.XX.XX.XX it should be 192.168.1.Y. I'll give clues for you to find the issue else I fear I'll find there are still missing informations: the container has to NAT the host: you need a MASQUERADE rule on the container. the host needs a gateway: its default route must be via 192.168.0.1 or you get those strange ARPs

– A.B
Jan 16 at 20:46














@A.B ip on host0 is 169.254.99.31 and ip for lxc0 is 169.254.99.30, somehow its not taking the 192.168.0.1 for lxc0 i just now tried superuser.com/questions/938805/…, still it does not work default route on host is 169.254.99.31

– enthu
Jan 16 at 20:50






@A.B ip on host0 is 169.254.99.31 and ip for lxc0 is 169.254.99.30, somehow its not taking the 192.168.0.1 for lxc0 i just now tried superuser.com/questions/938805/…, still it does not work default route on host is 169.254.99.31

– enthu
Jan 16 at 20:50














Well fix your host's host0 to be in the 192.168.0.0/24 range (I don't know what's the problem), and fix the container in LXC by not configuring at all lxc0 by the container's OS: LXC already configured it. don't even declare an lxc0 interface. There are too many small issues at once. Try to solve them then rework your question to have all those informations ready

– A.B
Jan 16 at 20:57






Well fix your host's host0 to be in the 192.168.0.0/24 range (I don't know what's the problem), and fix the container in LXC by not configuring at all lxc0 by the container's OS: LXC already configured it. don't even declare an lxc0 interface. There are too many small issues at once. Try to solve them then rework your question to have all those informations ready

– A.B
Jan 16 at 20:57











0






active

oldest

votes











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494692%2flxc-container-has-internet-access-how-to-access-internet-from-host%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494692%2flxc-container-has-internet-access-how-to-access-internet-from-host%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?