The KVM host is acting as a gateway / firewall for all of the virtual machine's it runs. It has a /26 public IP space configured on LAN interface em1: It has a /30 rfc1918 IP configured on WAN interface em2:

em2 terminates on a cisco router over this private IP. All of the virtual machine hosts with a Public IP are being routed to the internet through the gateway. I can access the IP address on em1 from the internet as well.

The problem is the gateway cannot reach the internet (it cannot initiate traffic requests) because it's WAN interface em2 has a private IP and it's sourcing internet requests from the private IP (, I want the linux gateway to source it's traffic out of em2 using it's IP address ( from em1 (it's Lan interface).

This is a way to save an IP and keep the kvm host as the gateway / Firewall to centrally manage the traffic for all of it's hosts instead of allowing the cisco router to act as the gateway. (This is a DataCenter network, I don't want the Cisco Router acting as the gateway / firewall, I want that terminated right at the kvm host)

Does anybody have any suggestions on how to configure iptables or bird to set this up? I've been smacking my head against a keyboard trying to figure it out.


Suggestions on how to configure iptables:

Open a terminal,

Press Ctrl+Alt+T

Run it:

sudo -i
/sbin/iptables -t nat -A POSTROUTING -o em2 -j MASQUERADE
/sbin/iptables -A INPUT -s -i em1 -j ACCEPT
echo “1” >/proc/sys/net/ipv4/ip_forward

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.