remapping ip addresses: how?

Discussion in 'Linux Networking' started by Alessandro Russo, Sep 6, 2006.

  1. Hi,

    sorry if the question is silly for thus ng, but I have already
    tried to answer for the whole day without results.

    I need a way to remap an IP address to another, in such a way that
    all the traffic directed to, say, 1.2.3.4, will go to 10.20.30.40.

    In particular, 1.2.3.4 is an external ip while 10.20.30.40 is my
    local ip.

    In other words, I need a way to specify that the traffic directed
    to a certain external ip will instead be routed to my local ip.

    I have Fedora Core 5.

    Thanks in advance for any help.

    Alessandro
     
    Alessandro Russo, Sep 6, 2006
    #1
    1. Advertisements

  2. Yes, that's commonly called 'NAT' or Network Address Translations,
    see the IPTable documentation for DNAT (Destination NAT)

    Davide
     
    Davide Bianchi, Sep 6, 2006
    #2
    1. Advertisements

  3. I have tried, but I don't understand what I have to do.
    I tried what I found at

    http://openskills.info/topic.php?ID=125

    but no way.

    Any hints? Thanks again.

    Ale
     
    Alessandro Russo, Sep 6, 2006
    #3

  4. The "Linux Home Server HOWTO" looks exactly like what you want
    and was updated to suit FC 5:

    http://www.brennan.id.au/

    As already mentioned "Destination NAT" is what you want, not that
    I have ever used this document but it seems from a short look
    well written.

    I'd urge you to check the chapter about yum, you can ease up
    installing/updating software pretty much if using 'yum'!

    Good luck

    [..]
     
    Michael Heiming, Sep 6, 2006
    #4
  5. I tried

    iptables -t nat -A PREROUTING -d 1.2.3.4 -j DNAT --to-destination 10.20.30.40

    with no effects.

    As far I understood, this should redirect to 10.20.30.40 everything that
    was originally directed to 1.2.3.4. Or I'm wrong?

    Ale
     
    Alessandro Russo, Sep 6, 2006
    #5
  6. There is more then a single command needed and I can't look into
    your box. Did you worked through the documentation I pointed out
    to you?

    You can see your nat setup with '/sbin/iptables -t nat -nvL',
    again all this is in the howto, you just need to work trough it.

    Good luck
     
    Michael Heiming, Sep 6, 2006
    #6
  7. sbin/iptables -t nat -nvL says:

    Chain PREROUTING (policy ACCEPT 1607 packets, 84568 bytes)
    pkts bytes target prot opt in out source destination
    0 0 DNAT all -- * * 0.0.0.0/0 149.132.103.59

    to:1.60.153.33

    where "to:1.60.153.33" is on the right of 149.132.103.59.

    It seems ok to me, but it should be wrong.

    Ale
     
    Alessandro Russo, Sep 6, 2006
    #7
  8. It seems wrong to me. Please start reading and using the "Linux
    Home Server HOWTO" now!

    http://www.brennan.id.au/
     
    Michael Heiming, Sep 7, 2006
    #8
  9. Hello,

    Alessandro Russo a écrit :
    Try :

    iptables -t nat -A OUTPUT -d 1.2.3.4 -j DNAT --to 10.20.30.40

    The OUTPUT chain sees locally generated packets whereas PREROUTING sees
    incoming packets.
     
    Pascal Hambourg, Sep 7, 2006
    #9
  10. Thanks a lot, it worked.

    Ale
     
    Alessandro Russo, Sep 7, 2006
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.