As far as the Feds are concerned, for firearm purchases, an active duty member of the military is a resident of the state where his/her duty station is located.
ATF Online - Firearms - Frequently Asked Questions - Unlicensed Persons
"Q: What constitutes residency in a State?
The State of residence is the State in which an individual is present; the individual also must have an intention of making a home in that State. A member of the Armed Forces on active duty is a resident of the State in which his or her permanent duty station is located. If a member of the Armed Forces maintains a home in one State and the member’s permanent duty station is in a nearby State to which he or she commutes each day, then the member has two States of residence and may purchase a firearm in either the State where the duty station is located or the State where the home is maintained."
When I was active-duty, I maintained a home of record in the state where I enlisted, and kept that state's driver's license. However, I was legally able to buy firearms in every state I was stationed in, after meeting that state's residency requirements (usually 60-90 days of residence, and showing something like a utility bill with your name and local address on it). In some states, it's easier to get a state ID card and use it for proof of residency/address for firearm purchases. A state-issued concealed-carry permit also works for most folks.
However, we ARE talking about California here. No telling WHAT weird state (and even local) laws might be floating around on the Left Coast. Make sure you check with one or more local FFL (Federally licensed) gun dealers, gunshops or sporting goods stores; it is their business to sell guns, and they WANT to sell guns, so if they are near a military installation they will know (and be happy to tell you) exactly what is required for them to successfully and legally tap that source of customers.
"Placement is power" -- seen in an article by Stephen A. Camp
(RIP, Mr. Camp; you will be remembered, and missed)