Created
April 17, 2013 19:35
-
-
Save szaydel/5407089 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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