Difference between revisions of "Solaris zones virtual networking with NAT"

From Aram's Wiki
Jump to: navigation, search
(Created page with " # 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-...")
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
# prepare the GZ; net2 is the interface connected to the Internet.  
+
[[Category:Solaris]]
 +
[[Category:Networking]]
 +
 
 +
Prepare the GZ; net2 is the interface connected to the Internet.  
 
  dladm create-etherstub ether0  
 
  dladm create-etherstub ether0  
 
  dladm create-vnic -l ether0 vnic0  
 
  dladm create-vnic -l ether0 vnic0  
Line 11: Line 14:
 
  svcadm enable network/ipfilter  
 
  svcadm enable network/ipfilter  
 
   
 
   
# prepare the zone; for-sysroot is the zone name.  
+
Prepare the zone; for-sysroot is the zone name.  
 
  dladm create-vnic -l ether0 vnic1  
 
  dladm create-vnic -l ether0 vnic1  
 
  zonecfg -z for-sysroot "create; set ip-type=exclusive; add net; set physical=vnic1; end; commit"  
 
  zonecfg -z for-sysroot "create; set ip-type=exclusive; add net; set physical=vnic1; end; commit"  
Line 18: Line 21:
 
  # in sys-config set up vnic1/v4 10.0.0.2/8 with 10.0.0.1 as default router.
 
  # in sys-config set up vnic1/v4 10.0.0.2/8 with 10.0.0.1 as default router.
 
   
 
   
# delete the zone  
+
Delete the zone.
 
  zoneadm -z for-sysroot shutdown  
 
  zoneadm -z for-sysroot shutdown  
 
  zoneadm -z for-sysroot uninstall -F  
 
  zoneadm -z for-sysroot uninstall -F  
Line 24: Line 27:
 
  dladm delete-vnic vnic1  
 
  dladm delete-vnic vnic1  
 
   
 
   
# restore GZ to original state  
+
Restore GZ to original state.
 
  routeadm -u -d ipv4-forwarding  
 
  routeadm -u -d ipv4-forwarding  
 
  ipadm delete-addr vnic0/v4  
 
  ipadm delete-addr vnic0/v4  

Latest revision as of 10:30, 22 February 2019


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