# Adding a route to an iface alias

## dulrich

Hi,

I want to add a route for some subnets on a specific interface alias. In need my outgoing traffic coming from a specific IP (there is ACL somewhere). Problem is that IP is on an alias and I can't have my routes on alias with "route".

```
config_vlan79=( "MY.PUB.LIC.IP/24"

       "MY.PUBLIC.IP.FORACL/24"

       "MYIPV6/64")
```

"MY.PUB.LIC.IP/24" and "MY.PUBLIC.IP.FORACL/24" are on the same subnet !

ifconfig gives :

```
vlan79   Link encap:Ethernet  HWaddr   

          inet addr:MY.PUB.LIC.IP  Bcast:MY.PUB.LIC.IP.255  Mask:255.255.255.0

          inet6 addr: MYIPV6/64 Scope:Global

          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1

          RX packets:1035 errors:0 dropped:0 overruns:0 frame:0

          TX packets:183 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:57399 (56.0 KiB)  TX bytes:27843 (27.1 KiB)

vlan79:1 Link encap:Ethernet  HWaddr  

          inet addr:MY.PUBLIC.IP.FORACL  Bcast:MY.PUBLIC.IP.FORACL.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1

```

adding a route for a subnet to device vlan79:1 doesn't work...

----------

## massimo

 *dulrich wrote:*   

> 
> 
> adding a route for a subnet to device vlan79:1 doesn't work...

 

... does not help me when I should help you. Please, be more precise.

----------

## dulrich

 *massimo wrote:*   

>  *dulrich wrote:*   
> 
> adding a route for a subnet to device vlan79:1 doesn't work... 
> 
> ... does not help me when I should help you. Please, be more precise.

 

yep sorry.

if I "route add -net 10.0.0.0/8 dev vlan79:1", route (or netstat) shows :

```
10.0.0.0   *               255.0.0.0   U     0      0        0 vlan79
```

instead of the alias vlan79:1. After a try, packets are really sent from the vlan79 instead of vlan79:1.

----------

## massimo

What does 

```
cat /proc/sys/net/ipv4/ip_forward
```

 return?

----------

## dulrich

It returns 0.

But do I need to enable ip forwarding in order to use a specific IP for outgoing packets (only) ?

----------

## massimo

Does it work when you enable it?

----------

## dulrich

Hum, in fact my test was very bad. The "route add -net 10.0.0.0/8 dev vlan79:1" works well, even if route doesn't show the specific alias.

Thanks and sorry for your time.

----------

## papahuhn

Take a look at "ip route". There should be an additional "src x.y.z" for the aliased device.

----------

