Skip to content

Instantly share code, notes, and snippets.

@genneko
Last active January 24, 2019 03:14
Show Gist options
  • Save genneko/b923346b14c301f37fa3ac5ce2387b8a to your computer and use it in GitHub Desktop.
Save genneko/b923346b14c301f37fa3ac5ce2387b8a to your computer and use it in GitHub Desktop.
$ jls
JID IP Address Hostname Path
1 r1 /vm/r1
2 vpnr1 /vm/vpnr1
3 vpnr2 /vm/vpnr2
4 vpnh1 /vm/vpnh1
5 vpnh2 /vm/vpnh2
$ jls -s vnet name | fgrep vnet=1
vnet=1 name=r1
vnet=1 name=vpnr1
vnet=1 name=vpnr2
vnet=1 name=vpnh1
vnet=1 name=vpnh2
$ jls -s vnet name | fgrep vnet=1 | sed 's/.*name=//'
r1
vpnr1
vpnr2
vpnh1
vpnh2
$ jls -s vnet name | fgrep vnet=1 | sed 's/.*name=//' | sudo xargs -IJAIL sh -c "echo -n 'JAIL: '; jexec JAIL ifconfig -l "
r1: lo0 pflog0 vi1_r1 vi2_r1
vpnr1: lo0 pflog0 vi1_vpnr1 vri1_vpnr1 tun0
vpnr2: lo0 pflog0 vi2_vpnr2 vri2_vpnr2
vpnh1: lo0 pflog0 vri1_vpnh1
vpnh2: lo0 pflog0 vri2_vpnh2 tun0
$ for jail in $(jls -s vnet name | fgrep vnet=1 | sed 's/.*name=//'); do echo "$jail: $(sudo jexec $jail ifconfig -l)"; done
r1: lo0 pflog0 vi1_r1 vi2_r1
vpnr1: lo0 pflog0 vi1_vpnr1 vri1_vpnr1 tun0
vpnr2: lo0 pflog0 vi2_vpnr2 vri2_vpnr2
vpnh1: lo0 pflog0 vri1_vpnh1
vpnh2: lo0 pflog0 vri2_vpnh2 tun0
$ sudo vnet list
vri2
vi1
vri1
vi2
$ sudo vnet list vri2
vri2_vpnh2
vri2_vpnr2
$ for vnet in $(sudo vnet list); do echo $vnet; sudo vnet list $vnet | sed 's/^/ /'; done
vri2
vri2_vpnh2
vri2_vpnr2
vi1
vi1_r1
vi1_vpnr1
vri1
vri1_vpnh1
vri1_vpnr1
vi2
vi2_r1
vi2_vpnr2
$ for vnet in $(sudo vnet list); do echo $vnet; sudo vnet list $vnet | sed 's/^/ /' | xargs -IVIF sh -c 'echo -n " VIF - "; for jail in $(jls -s vnet name | fgrep vnet=1 | sed 's/.*name=//'); do echo "$jail: $(sudo jexec $jail ifconfig -l)"; done | grep VIF | cut -f1 -d:'; done
vri2
vri2_vpnh2 - vpnh2
vri2_vpnr2 - vpnr2
vi1
vi1_r1 - r1
vi1_vpnr1 - vpnr1
vri1
vri1_vpnh1 - vpnh1
vri1_vpnr1 - vpnr1
vi2
vi2_r1 - r1
vi2_vpnr2 - vpnr2
$ sudo vnet list_jail
r1
vpnr1
vpnr2
vpnh1
vpnh2
$ sudo vnet list_jail -l
r1: lo0 pflog0 vi1_r1 vi2_r1
vpnr1: lo0 pflog0 vi1_vpnr1 vri1_vpnr1 tun0
vpnr2: lo0 pflog0 vi2_vpnr2 vri2_vpnr2
vpnh1: lo0 pflog0 vri1_vpnh1
vpnh2: lo0 pflog0 vri2_vpnh2 tun0
$ sudo vnet list -r
vri2
vpnh2 vri2_vpnh2 192.168.2.11/24
vpnr2 vri2_vpnr2 192.168.2.1/24
vi1
r1 vi1_r1 172.31.1.1/24 2001:db8:10:1::1/64, fe80::ffff:fe00:ff00%vi1_r1/64
vpnr1 vi1_vpnr1 172.31.1.11/24
vri1
vpnh1 vri1_vpnh1 192.168.1.11/24
vpnr1 vri1_vpnr1 192.168.1.1/24
vi2
r1 vi2_r1 172.31.2.1/24 2001:db8:10:2::1/64, fe80::feff:fe01:fe01%vi2_r1/64
vpnr2 vi2_vpnr2 172.31.2.11/24
$ sudo vnet list -rl
vri2
vpnh2
vri2_vpnh2
192.168.2.11/24
vpnr2
vri2_vpnr2
192.168.2.1/24
vi1
r1
vi1_r1
172.31.1.1/24
2001:db8:10:1::1/64, fe80::ffff:fe00:ff00%vi1_r1/64
vpnr1
vi1_vpnr1
172.31.1.11/24
vri1
vpnh1
vri1_vpnh1
192.168.1.11/24
vpnr1
vri1_vpnr1
192.168.1.1/24
vi2
r1
vi2_r1
172.31.2.1/24
2001:db8:10:2::1/64, fe80::feff:fe01:fe01%vi2_r1/64
vpnr2
vi2_vpnr2
172.31.2.11/24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment