An interionic potential for silica which is derived by fitting the parameters to data generated by Car-Parrinello molecular-dynamics (CPMD) simulations. It reproduces accurately the liquid structure generated by the CPMD trajectories, the experimental activation energies for the self-diffusion constants and the experimental density of amorphous silica. Also lattice parameters and elastic constants of α-quartz are well reproduced, showing the transferability of this potential.