# how to use IF aliases for outgoing packets?



## alware (Nov 12, 2009)

I do have physical inteface if0
which is carrying several IPs

```
ifconfig_if0="inet xxx.xxx.xxx.xxx"
ifconfig_if0_alias0="inet yyy.yyy.yyy.yyy"
ifconfig_if0_alias1="inet zzz.zzz.zzz.zzz"
```
how can I manage the outgoing traffic to flow from different ips?

e.g. rinetd uses yyy.yyy.yyy.yyy
and postfix knocks out via zzz.zzz.zzz.zzz

now all goes through the first  xxx


----------



## pbd (Nov 12, 2009)

You cau use NAT in pf(). For example to map all outgoing traffic on port 25 to zzz.zzz.zzz.zzz:


```
nat on if0 proto tcp port = 25 -> zzz.zzz.zzz.zzz
```


----------



## pbd (Nov 12, 2009)

See [post]37707[/post].


----------



## alware (Nov 12, 2009)

pbd thanx

but can I use for that ipfw/natd?


----------



## DutchDaemon (Nov 12, 2009)

NAT is NAT in any packet filter. Note that ipfw now incorporates NAT (in-kernel), so you don't need a separate instance of natd anymore.

See the NETWORK ADDRESS TRANSLATION chapter in ipfw(8).


----------



## alware (Nov 12, 2009)

thanx	
DutchDaemon


----------



## alware (Nov 15, 2009)

Unfortunately there's no solution for the aforecited problem using NAT.


----------



## dinoex@ (Nov 16, 2009)

Normaly you have to tell each application which IP they should bind to.

a few examples:

```
ping -S yyy.yyy.yyy.yyy www.example.com
```


```
traceroute -s yyy.yyy.yyy.yyy www.example.com
```


```
ssh -b yyy.yyy.yyy.yyy www.example.com
```


----------

