Posts Tagged ‘iptables’

iptables

Friday, October 3rd, 2008

Since I’m always forgetting, the following is necessary on the host box if you’re running virtual machines w/ networking configured in NAT mode:

# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

This also requires:

# sysctl -w net.ipv4.ip_forward=1

The entry below simply port forwards 2222 on the host to the virtual machine:

# iptables -t nat -A PREROUTING -p tcp --dport 2222 -j DNAT --to 192.168.237.2:22

Routing mail out through an additional IP

Monday, June 9th, 2008

In this example, we’ll say the additional IP we want to route mail out through is 1.2.3.4.

Now, there are two ways to do this. The first is to use iptables:

# iptables -t nat -A POSTROUTING -p tcp --dport 25 -j SNAT --to-source 1.2.3.4

The second, assuming you’re using sendmail, can be done by adding the following to /etc/mail/sendmail.mc:

define(`confCLIENT_OPTIONS',`Address=1.2.3.4')dnl

Proceed to rebuild the /etc/sendmail.cf file and restart sendmail.