We study the design of optimal network codes of small alphabet size. We propose a linear programming approach for the design of optimal linear network codes (over GF(2), GF(3), and GF(4)), as well as a Monte Carlo Markov chain (MCMC) method for the design of nonlinear network codes. We will also present a few examples.