source ip masquerading

Discussion in 'Site & Server Administration' started by almecho, Feb 17, 2009.

  1. #1
    I've got a problem on one of my boxes I'm trying to resolve. I need to have named making it's outbound connections from a different source IP address than the primary one assigned to the server.

    eg. Primary IP is 1.2.3.4 with secondary IP address 2.3.4.5. When a dns request is made by the server now to a remote name server is uses 1.2.3.4 as the default source address for the request but I want the request to appear as if it's coming from 2.3.4.5 instead as that's where all the other requests on the server are going through.

    I'm pretty sure that this can be done with some iptables routing rules but I'm having trouble getting my head around the correct syntax required.

    Little help?
     
    almecho, Feb 17, 2009 IP
  2. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #2
    iptables -t nat -I POSTROUTING -p udp -s 1.2.3.4 -j SNAT --to-source 2.3.4.5

    test the above rule and/or do more research on iptables and snat.
     
    buldozerceto, Feb 18, 2009 IP