# Understanding routing table in a jail



## Michael-O (Mar 6, 2019)

Folks,

I  just started using jails via ezjail(8). After having created the very first jail (resolv.conf copied from host) with a local and internal IP address I do not understand the routing table.

On the host I have:

rc.conf:


```
# Network
ifconfig_bge0="inet 147.54.64.17  netmask 255.255.252.0"
defaultrouter="147.54.64.1"

# Jail Configs
cloned_interfaces="lo1"
ifconfig_lo1_aliases="inet 127.0.1.1-7/29"
ezjail_enable="YES"
```

Created the jail:

```
ezjail-admin create deblndw011x1j.ad001.siemens.net 'lo1|127.0.1.2,bge0|147.54.64.55'
```

This is `ifconfig` after the jail has been started:


```
2488 # ifconfig
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
        ether 20:67:7c:d4:58:40
        inet 147.54.64.17 netmask 0xfffffc00 broadcast 147.54.67.255
        inet 147.54.64.55 netmask 0xffffffff broadcast 147.54.64.55
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet 127.0.1.1 netmask 0xfffffff8
        inet 127.0.1.3 netmask 0xffffffff
        inet 127.0.1.4 netmask 0xffffffff
        inet 127.0.1.5 netmask 0xffffffff
        inet 127.0.1.6 netmask 0xffffffff
        inet 127.0.1.7 netmask 0xffffffff
        inet 127.0.1.2 netmask 0xffffffff
        groups: lo
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
```

and its routing table:

```
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
default            147.54.64.1        UGS        bge0
127.0.0.1          link#5             UH          lo0
127.0.1.1          link#6             UH          lo1
127.0.1.2          link#6             UH          lo1
127.0.1.3          link#6             UH          lo1
127.0.1.4          link#6             UH          lo1
127.0.1.5          link#6             UH          lo1
127.0.1.6          link#6             UH          lo1
127.0.1.7          link#6             UH          lo1
147.54.64.0/22     link#1             U          bge0
147.54.64.17       link#1             UHS         lo0
147.54.64.55       link#1             UHS         lo0
147.54.64.55/32    link#1             U          bge0
```

new the jail:


```
bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
        ether 20:67:7c:d4:58:40
        inet 147.54.64.55 netmask 0xffffffff broadcast 147.54.64.55
        media: Ethernet autoselect (1000baseT <full-duplex>)
        status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        groups: lo
lo1: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
        inet 127.0.1.2 netmask 0xffffffff
        groups: lo
```

and the jail's routing table:

```
Routing tables

Internet:
Destination        Gateway            Flags     Netif Expire
127.0.1.2          link#6             UH          lo1
147.54.64.55       link#1             UHS         lo0
```

My questions now are:

Why is there lo0 on the jail when I have assigned lo1 as the first interface?
Why is the jail's routing table so empty, why is bge0 not listed and no default gateway?
Is the jail usable with this network configuration?
DNS resolution works, fetch works too.

Thanks a lot!


----------



## tokred (Mar 6, 2019)

A standard jail does not have an "own" routing table. Instead, networking and routes are handled by the host. Think of jail networking more as of a "filtered/masked view" on host interfaces and IPs.

If you require a full network stack inside a jail, including dedicated routing table, have a look at vnet(9).

Regards


----------



## Michael-O (Mar 6, 2019)

Alright, this makes sense. This is actually what I have assumed. 
I don't need another network stack for the jail. I am happy how it works right now.

Thank you!


----------

