Skip to content

Instantly share code, notes, and snippets.

@szaydel
Created April 17, 2013 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save szaydel/5407089 to your computer and use it in GitHub Desktop.
Save szaydel/5407089 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Simple Ad Hoc SmartOS Setup Service
set -o xtrace
. /lib/svc/share/smf_include.sh
cd /
PATH=/usr/sbin:/usr/bin:/opt/custom/bin:/opt/custom/sbin; export PATH
case "$1" in
'start')
#### Basic networking
hostname "smartos01" && hostname > /etc/nodename
dladm create-vnic -l vswitch0 vnic101
ifconfig vnic101 plumb 10.0.0.1/8 up
routeadm -u -e ipv4-forwarding
### NAT rules
cat << EOF >> /etc/ipf/ipnat.conf
map e1000g0 10.0.0.0/8 -> 0/32 portmap tcp/udp auto
map e1000g0 10.0.0.0/8 -> 0/32
EOF
### FW rules
cat << EOF >> /etc/ipf/ipf.conf
# Here will be the firewall rules
EOF
### launch ipfilter and load the NAT rules
svcadm enable ipfilter
ipnat -f /etc/ipf/ipnat.conf
;;
'stop')
### Insert code to execute on shutdown here.
;;
*)
echo "Usage: $0 { start | stop }"
exit $SMF_EXIT_ERR_FATAL
;;
esac
exit $SMF_EXIT_OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment