Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
make nat work with kvm running debian, raw file, I will redo this tomorrow and make sure nothing unnecessary is here
vmadm list
# remove your previous try
export ID=`vmadm list|grep run|cut -b-36` ; echo $ID
export ID=`vmadm list|grep stop|cut -b-36` ; echo $ID
vmadm stop $ID
vmadm destroy $ID
script
dladm show-phys -m
dladm show-link
dladm show-vnic
ifconfig -a
dladm create-vnic -l vswitch0 vnic6
dladm create-vnic -l vswitch0 net0
dladm create-vnic -l e1000g0 net0
dladm show-vnic
# DELETE VNIC
ifconfig vnic6 unplumb
ifconfig net0 unplumb
dladm delete-vnic vnic6
dladm delete-vnic net0
dladm show-vnic
netstat -rn
# VNIC
ifconfig -a
ifconfig vnic6 plumb
ifconfig net0 plumb
ifconfig vnic6 192.168.1.1/24 up
ifconfig net0 192.168.0.1/24 up
netstat -rn
vmadm list
vmadm create <<EOF
{ "brand": "kvm",
"alias": "debian1",
"autoboot": false,
"vcpus": 2,
"ram": 1024,
"disks": [{
"boot": true,
"image_uuid": "debian1",
"model": "virtio",
"size": 40960
}],
"default_gateway": "192.168.0.1",
"resolvers": [ "10.17.42.3", "8.8.8.8" ],
"nics": [{
"nic_tag": "external",
"model": "e1000",
"ip":"192.168.0.2",
"netmask": "255.255.254.0",
"gateway": "192.168.0.1",
"primary": true
}]
}
EOF
export ID=`vmadm list|grep debian|cut -b-36` ;echo $ID
tail -F /zones/$ID/root/tmp/vm.log &
vmadm boot $ID
vmadm list
dladm reset-linkprop -z $ID -p protection net0
dladm show-linkprop -z $ID
dladm show-phys -m
dladm show-vnic
dladm show-link
netstat -rn
ping -s 192.168.0.2 156 3
ipnat -l
vmadm info $ID vnc
ssh root@192.168.0.2
routeadm -u -e ipv4-forwarding
routeadm -u -e ipv4-routing
routeadm
svcadm enable network/ipfilter
cat > /etc/ipf/ipnat.conf<<EOF
map e1000g0 192.168.0.0/24 -> 0/32 portmap tcp/udp auto
map e1000g0 192.168.0.0/24 -> 0/32
EOF
cat /etc/ipf/ipnat.conf
svcadm disable network/ipfilter
svcadm enable network/ipfilter
ipnat -l
routeadm
netstat -rn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.