Bobcares

LXC container network configuration – how we setup

by | Dec 22, 2019

Trying to setup an LXC container network configuration? We can help you with it.

The network plays an important role in containers. We can configure the network as per our infrastructure.

At Bobcares, we often get requests to configure a network in LXC as part of our Server Management Services.

Today, let’s get into the details and see how our Support Engineers configure the network.

 

More about LXC Network configuration

LXC creates its own device which is managed by the lxc-net service.

lxc-net is a part of LXC. It allows us to setup a bridge in the container with ipv4.

There are multiple methods to setup a network. And multiple ways to configure it.

Let’s discuss how to configure an additional network interface in LXC. Also, let’s discuss setting up a bridge using lxc-net.

 

Add an additional network interface in LXC

Recently one of our customers contacted us to add a network in LXC. Let’s see how our Support Engineers add a network interface in LXC.

Initially, we add the entry in the containers configuration file. The file is located at /var/lib/lxc/CONTAINER-NAME/config

The location can change based on the configuration.

When we open the file, already a network interface detail will be present. We duplicate the entry or add the below details.

lxc.network.mtu = 1500
lxc.network.type = XXXX
lxc.network.name = ethx
lxc.network.link = XXX
lxc.network.ipv4 = 1xx.2x.1xx.2x
lxc.network.flags = up

Also, we make sure the details we enter in the second interface are right. After that we save the file.

Then we restart the network service.

Now on checking, two interfaces will be displayed.

 

Configure a bridge in LXC

By default, the bridge interface is not configured. Let’s discuss how our Support Engineers configure a bridge interface.

We open the file /etc/lxc/default.conf. The file location can change according to the configuration.

lxc.network.type = xxxx
lxc.network.link = Bridge name
lxc.network.flags = up
lxc.network.hwaddr = xx:xx:xx:xx:xx:xx

Now we create the /etc/default/lxc-net file and add the line

USE_LXC_BRIDGE="true"

Then we restart the lxc-net service using the command

systemctl restart lxc-net

Now we check the working using the command

ip -4 -o a show lxcbr0 bridge_name

LXC container network configuration

Finally, we have now configured the bridge for LXC containers.

 

A common error when configuring network in LXC

Recently one of the customers approached us saying the network configuration fails.

One of the common mistakes is a typo error. On analyzing the configuration, we found that the network configuration in the configuration file was incorrect.

Thus our Support Engineers resolved the error by making the necessary changes in the configuration file.

 

[Need assistance to set up a network in LXC containers? We’ll help you.]

 

Conclusion

In short, we’ve discussed the LXC container network configuration. Also, we’ve discussed how our Support Engineers configure and add two network interfaces in LXC, bridge in LXC and common mistakes when configuring a network.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF