Skip to contentSkip to conversation

ip alias

DISCUSSION John Black 3 participants 6 messages Sep 28, 2004 1 message not in the archive

lore
Share & tools
lore

John Black

author
#0 lore raw

I'm tryint to setup ip alias with iptables on fedora core 2.

Is this right? For some reason it will not let me out?

ifconfig eth0:0 192.168.1.23 netmask 255.255.255.0

iptables -t nat -A PREROUTING -d 192.168.1.23 -i eth0 \
                -j DNAT --to-destination 161.31.31.23

thanks
john

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#2 lore raw
Quoted 7 lines
Quoted 2 lines

ifconfig eth0:0 192.168.1.23 netmask 255.255.255.0

not this:

Quoted 2 lines
iptables -t nat -A PREROUTING -d 192.168.1.23 -i eth0 \
               -j DNAT --to-destination 161.31.31.23

but i want eth0:0 to be asigned that particular address to the internet.

#3 lore raw
Quoted 8 lines · John Black
Quoted 6 lines
Quoted 1 line

ifconfig eth0:0 192.168.1.23 netmask 255.255.255.0

not this:

Quoted 2 lines
iptables -t nat -A PREROUTING -d 192.168.1.23 -i eth0 \
               -j DNAT --to-destination 161.31.31.23

but i want eth0:0 to be asigned that particular address to the internet.

Then I think your rule it's Ok. It will redirect all the traffic with destination 192.168.1.23 to 161.31.31.23.

Signature · 12 lines
Jose Maria Lopez Hernandez
Director Tecnico de bgSEC
[email protected]
bgSEC Seguridad y Consultoria de Sistemas Informaticos
http://www.bgsec.com
ESPAÑA

The only people for me are the mad ones -- the ones who are mad to live,
mad to talk, mad to be saved, desirous of everything at the same time,
the ones who never yawn or say a commonplace thing, but burn, burn, burn
like fabulous yellow Roman candles.
                -- Jack Kerouac, "On the Road"
#4 lore raw
In reply to John Black

Quoting John Black <[email protected]>
Date: Mon, 27 Sep 2004 22:15:50

Quoted 7 lines

I'm tryint to setup ip alias with iptables on fedora core 2.

Is this right? For some reason it will not let me out?

ifconfig eth0:0 192.168.1.23 netmask 255.255.255.0

iptables -t nat -A PREROUTING -d 192.168.1.23 -i eth0 \
                -j DNAT --to-destination 161.31.31.23

Not quite sure what are you trying to do with above. You don't need iptables to set up an alias. The ifconfig or ip commands will suffice.

What do you want to achieve with iptables command? What it will do is that all packets addressed for 192.168.1.23 that arrive into box (not generated on the box) on interface eth0 will be sent to 161.31.31.23 (with that IP address as destination). Is that what you wanted to do?

Signature · 3 lines
Aleksandar Milivojevic <[email protected]>    Pollard Banknote Limited
Systems Administrator                           1499 Buffalo Place
Tel: (204) 474-2323 ext 276                     Winnipeg, MB  R3T 1L7
author
#5 lore raw
Quoted 5 lines

Not quite sure what are you trying to do with above. You don't need

iptables to

Quoted 3 lines

set up an alias. The ifconfig or ip commands will suffice.

What do you want to achieve with iptables command? What it will do is

that all

Quoted 1 line

packets addressed for 192.168.1.23 that arrive into box (not generated on

the

Quoted 1 line

box) on interface eth0 will be sent to 161.31.31.23 (with that IP address

as

Quoted 2 lines

destination). Is that what you wanted to do?

but the traffic from 192.168.1.23 that i need to go to the internet i would like to
have addressed as 161.31.31.23

john

#6 lore raw
Quoted 3 lines · John Black

but the traffic from 192.168.1.23 that i need to go to the internet i would like to
have addressed as 161.31.31.23

You need SNAT (source NAT), not DNAT (destination NAT). I'll assume eth0 has address 161.31.31.23:

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source 161.31.31.23

or if eth0 has dinamically allocated IP address:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUARADE

I'm not sure why you are assigning local IP address as an alias to your external interface (probably something you haven't mentioned), so I wan't comment on whether it is needed or not. Also, in case when you have multiple IP addresses (aliases) assigned to an interface, I'm not sure exactly how MASQUERADE target behaves. man iptables for more details and differences between SNAT and MASQUERADE targets.

Signature · 3 lines
Aleksandar Milivojevic <[email protected]>    Pollard Banknote Limited
Systems Administrator                           1499 Buffalo Place
Tel: (204) 474-2323 ext 276                     Winnipeg, MB  R3T 1L7