Solaris zones virtual networking with NAT

From Aram's Wiki
Jump to: navigation, search


Prepare the GZ; net2 is the interface connected to the Internet.

dladm create-etherstub ether0 
dladm create-vnic -l ether0 vnic0 
ipadm create-ip vnic0 
ipadm create-addr -T static -a 10.0.0.1/8 vnic0/v4 
routeadm -u -e ipv4-forwarding 
ipadm set-ifprop -p forwarding=on -m ipv4 net2 
ipadm set-ifprop -p forwarding=on -m ipv4 vnic0 
echo "map net2 10.0.0.0/8 -> 0/32 portmap tcp/udp auto" > /etc/ipf/ipnat.conf 
echo "map net2 10.0.0.0/8 -> 0/32" >> /etc/ipf/ipnat.conf 
svcadm enable network/ipfilter 

Prepare the zone; for-sysroot is the zone name.

dladm create-vnic -l ether0 vnic1 
zonecfg -z for-sysroot "create; set ip-type=exclusive; add net; set physical=vnic1; end; commit" 
zoneadm -z for-sysroot install 
zoneadm -z for-sysroot boot; zlogin -C for-sysroot 
# in sys-config set up vnic1/v4 10.0.0.2/8 with 10.0.0.1 as default router.

Delete the zone.

zoneadm -z for-sysroot shutdown 
zoneadm -z for-sysroot uninstall -F 
zonecfg -z for-sysroot delete -F 
dladm delete-vnic vnic1 

Restore GZ to original state.

routeadm -u -d ipv4-forwarding 
ipadm delete-addr vnic0/v4 
ipadm delete-ip vnic0 
dladm delete-vnic vnic0 
dladm delete-etherstub ether0 
ipadm set-ifprop -p forwarding=off -m ipv4 net2 
svcadm disable network/ipfilter 
rm /etc/ipf/ipnat.conf