Change UDP port with iptables for VPN clients

1

What I want to do is say that for all UDP connections on interface ppp0 that have a destination port of 53, change that destination port to 1053.

I am attempting to change the destination port of UDP packets for VPN clients connected via PPTP on Ubuntu.

This question:
https://stackoverflow.com/questions/242772/using-iptables-to-change-a-destination-port
suggests that this can be done using NAT at the --to-destination option, for example:

iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination x.x.x.x:1053

This does work but it changes the port for ALL packets going out on port 53 but I only want to change the port for some of my VPN clients who are connected on interface ppp0-255 and IP range 192.168.0.10-255.

I have tried adding the source into the statement, for example:

iptables -t nat -A OUTPUT -s 192.168.0.10 -p udp --dport 53 -j DNAT --to-destination x.x.x.x:1053

This however does not appear to work and the VPN connections still go through to port 53.

ant-fx

Posted 2013-05-29T08:17:09.173

Reputation: 193

No answers