LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Containers
User Name
Password
Linux - Containers This forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.

Notices


Reply
  Search this Thread
Old 09-18-2016, 09:27 AM   #1
ajnabi
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Rep: Reputation: 1
LXC Container--interface up, but no network connection in or out


Glad to see a Forum devoted to Containers!!!

I have been trying to get networking to work in my containers, yet to no avail. Having tried just about every configuration I could find on the web,

I decided to just scrap all configs and restart with a setup as per this page: https://tech.feedyourhead.at/content...-debian-jessie

Now, the guest interface comes up with the IP address, but no network connectivity.

I am starting to think there is something outside of my configs that is the problem, but not sure. I thought the best way to figure this out is to give as much info as possible and hopefully someone will spot the problem.

Here goes:

Host: Debian Jessie
Host Network Address: 192.168.0.163
Host Gateway: 192.168.0.1
Container: Debian Jessie
Container Network Address: 192.168.33.2
Container Gateway: 192.168.33.1

network-manager and wcid are not installed.

Not sure if this means anything but on lxc-start the container throws one error.

Code:
[  OK  ] Reached target Paths.
Failed to open /dev/autofs: No such file or directory
Failed to initialize automounter: No such file or directory
[FAILED] Failed to set up automount Arbitrary Executable File Formats File System Automount Point.
See 'systemctl status proc-sys-fs-binfmt_misc.automount' for details.
Unit proc-sys-fs-binfmt_misc.automount entered failed state.
[  OK  ] Reached target Swap.
Running the suggested command from within the container yields:

Code:
# systemctl status proc-sys-fs-binfmt_misc.automount
? proc-sys-fs-binfmt_misc.automount - Arbitrary Executable File Formats File System Automount Point
   Loaded: loaded (/lib/systemd/system/proc-sys-fs-binfmt_misc.automount; static)
   Active: failed (Result: resources)
    Where: /proc/sys/fs/binfmt_misc
     Docs: https://www.kernel.org/doc/Documentation/binfmt_misc.txt
           http://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
I read the "Docs" links... couldn't make much of it, but I don't think it's part of the problem, but would like verification of that.

Configs On Host:

Both /etc/default/lxc and /etc/lxc/default.conf are empty.

Code:
# cat /etc/network/interfaces
auto lo
 iface lo inet loopback

auto eth0
 iface eth0 inet manual

auto br0
 iface br0 inet static
 address 192.168.33.1
 netmask 255.255.255.0
 broadcast 192.168.33.255
 bridge_ports dummy0
 bridge_fd 2.0
 bridge_maxwait 1
Code:
# ifconfig |grep -A1 Ethernet
br0       Link encap:Ethernet  HWaddr fe:31:5f:ef:bf:9a
          inet addr:192.168.33.1  Bcast:192.168.33.255  Mask:255.255.255.0
--
eth0      Link encap:Ethernet  HWaddr 00:21:86:f0:5d:86
          inet addr:192.168.0.163  Bcast:192.168.0.255  Mask:255.255.255.0
--
vethJL4V0V Link encap:Ethernet  HWaddr fe:31:5f:ef:bf:9a
          inet6 addr: fe80::fc31:5fff:feef:bf9a/64 Scope:Link
--
virbr0    Link encap:Ethernet  HWaddr 0a:5b:ec:e0:14:a6
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
Container config:

Code:
# cat /var/lib/lxc/debian8_chat/config
lxc.start.auto = 0
lxc.network.type = empty
lxc.rootfs = /var/lib/lxc/debian8_chat/rootfs

# Common configuration
lxc.include = /usr/share/lxc/config/debian.common.conf

# Container specific configuration
lxc.mount = /var/lib/lxc/debian8_chat/fstab
lxc.utsname = debian8_chat
lxc.arch = amd64
lxc.autodev = 1
lxc.kmsg = 0
lxc.tty = 6

# Newtwork
lxc.network.type = veth
lxc.network.name = veth0
lxc.network.flags = up

## specify the interface to be used for real network traffic. 
lxc.network.link = br0
Container network interface file:

Code:
# cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto veth0
 iface veth0 inet static
 address 192.168.33.2
 netmask 255.255.255.0
 gateway 192.168.33.1
 dns-nameservers 192.168.33.1
Any help would be greatly appreciated.

Last edited by ajnabi; 09-18-2016 at 01:53 PM. Reason: Added More Info
 
Old 09-19-2016, 05:12 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Not seeing anywhere in that tutorial where it says to enable forwarding.

To check:
Code:
cat /proc/sys/net/ipv4/ip_forward
To enable:
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
 
Old 09-19-2016, 06:04 PM   #3
ajnabi
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 1
Quote:
Not seeing anywhere in that tutorial where it says to enable forwarding.
Ahh... good point... you're right. I forgot to mention I have the following in my iptables script--which hopefully is correct.

Code:
iptables -P FORWARD  ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Just to check:

Code:
# cat /proc/sys/net/ipv4/ip_forward
1
 
Old 09-21-2016, 06:29 AM   #4
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
Have you checked out the Debian Wiki page on LXC? Worked for me. https://wiki.debian.org/LXC

I also notice you have two network.type entries, one being empty. I don't know how LXC works, if it follows the first encountered instance or the last. Try commenting out the first.

Which method are you using? I am using a simple bridge.

My network configuration, for reference. I notice you lack an ip entry:

Code:
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.ipv4 = 0.0.0.0/24
/etc/default/lxc-net:
Code:
USE_LXC_BRIDGE="true"
LXC_BRIDGE="br0"
LXC_ADDR="10.0.0.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.0.0/24"
LXC_DHCP_RANGE="10.0.0.2,10.0.0.254"
LXC_DHCP_MAX="253"
LXC_DHCP_CONFILE=""
LXC_DOMAIN=""
Don't forget to start the 'lxc-net' service on the host.

Last edited by goumba; 09-21-2016 at 06:30 AM.
 
Old 09-22-2016, 06:50 PM   #5
ajnabi
LQ Newbie
 
Registered: Sep 2009
Posts: 15

Original Poster
Rep: Reputation: 1
Quote:
Have you checked out the Debian Wiki page on LXC? Worked for me. https://wiki.debian.org/LXC
Yes, thanks, I have tried it.

Quote:
I also notice you have two network.type entries, one being empty. I don't know how LXC works, if it follows the first encountered instance or the last. Try commenting out the first.
Nope, commenting it out doesn't change anything. Apparently "several network virtualization types can be specified for the same container" as per lxc.container.conf man page. I used it because it was in the tutorials I linked above.

Quote:
Which method are you using? I am using a simple bridge.

My network configuration, for reference. I notice you lack an ip entry:
Thanks for posting your config. I just tried the simple bridge after reading your post. My container is not getting any IP address.

Are running dnsmasq?
Are you setting any iptables rules?
 
Old 09-23-2016, 03:30 AM   #6
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Fedora, OpenSUSE, FreeBSD, OpenBSD, macOS (hack). Past: Debian, Arch, RedHat (pre-RHEL).
Posts: 1,335
Blog Entries: 7

Rep: Reputation: 402Reputation: 402Reputation: 402Reputation: 402Reputation: 402
No, I just followed the guide for Simple Bridge. No dnsmasq set up, no IP tables rules.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXC Container: sound Not working charlie101 Linux - Virtualization and Cloud 11 04-14-2020 01:15 AM
[SOLVED] Internet acces for LXC container TWfromSWD Linux - Networking 3 06-14-2016 01:52 PM
[SOLVED] lxc new container how to set password jzoudavy Linux - Newbie 1 09-01-2015 01:52 PM
How to use Local ISO for LXC Container? sunveer Linux - Software 0 10-04-2013 04:44 AM
How to end a Linux Container (LXC) from within? Skaperen Linux - Virtualization and Cloud 0 06-14-2011 09:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Containers

All times are GMT -5. The time now is 08:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration