In this study the modes produced by a defect inserted in a macroporous silicon (MP) photonic crystal (PC) have been studied theoretical and experimentally. In particular, the transmitted and reflected spectra have been analyzed for variations in the defect’s length and width. The performed simulations show that the resonant frequency is more easily adjusted for the fabricated samples by length tuning rather than width. The optimum resonance peak results when centered in the PC bandgap. The changes in the defect geometry result in small variations of the optical response of the PC. The resonance frequency is most sensitive to length variations, while the mode linewidth shows greater change with the defect width variation. Several MPS photonic crystals were fabricated by the electrochemical etching (EE) process with optical response in the range of 5.8 µm to 6.5 µm. Results of the characterization are in good agreement with simulations. Further samples were fabricated consisting of ordered modulated pores with a pitch of 700 nm. This allowed to reduce the vertical periodicity and therefore to have the optical response in the range of 4.4 µm to 4.8 µm. To our knowledge, modes working in this range of wavelengths have not been previously reported in 3-d MPS structures. Experimental results match with simulations, showing a linear relationship between the defect’s length and working frequency inside the bandgap. We demonstrate the possibility of tailoring the resonance peak in both ranges of wavelengths, where the principal absorption lines of different gases in the mid infrared are placed. This makes these structures very promising for their application to compact gas sensors.