Tuesday, January 5, 2016

Konfigurasi Network LXC Container

Configurasi network LXC :

1. buat bridge di interface

location file : /etc/network/interfaces

Configur kurang lebih seperti ini
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
#dns-nameservers 192.168.1.101

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
        address 10.11.21.149/24
        gateway 10.11.21.1
        dns-nameservers 192.168.1.101
        #address 203.130.242.162/29
        #gateway 203.130.242.16

auto br1
iface br1 inet static
        address 10.11.21.113
        network 10.11.21.0
        netmask 255.255.255.0
        broadcast 10.11.21.255
        gateway 10.11.21.1
        bridge_ports eth0
        #bridge_fd 9
        #bridge_hello 2
       # bridge_maxage 12
       # bridge_stp off
        dns-nameservers 192.168.1.101
Ket :      
Address di br1 cari ip yang masih kosong/belum digunakan

2. Running Config interfaces yang baru dibuat dengan command : ifup br1
3. Config lxc :
Locate : /var/lib/lxc/nama container/config

Isi config Container :

# Template used to create this container: /usr/share/lxc/templates/lxc-ubuntu
# Parameters passed to the template:
# For additional config options, please look at lxc.container.conf(5)

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

# Container specific configuration
lxc.rootfs = /var/lib/lxc/fr2/rootfs
lxc.mount = /var/lib/lxc/fr2/fstab
lxc.utsname = fr2
lxc.arch = amd64

# Network configuration
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br1
lxc.network.hwaddr = 00:16:3e:c4:56:fa

lxc.network.ipv4 = 10.11.21.117/32
lxc.network.ipv4.gateway = 10.0.0.1

4. restart lxc container command :
  --> Stop lxc-stop -n fr2
  --> Start lxc-start -n fr2

5. Check ping  10.11.21.117 dari pc lain

6. Selesai lxc container dapat diakses dari pc lain

NB :
Kalau terjadi kesalahan pembuatan bridge dapat dilakukan delete bridge dengan command berikut :
 # ip link set br100 down
 # brctl delbr br100

Capture akan segera menyusul... :)

No comments :

Post a Comment