Dynamic interface using iproute2

Gustavo Schroeder gutosch at gmail.com
Thu Jan 28 11:42:01 UTC 2010


On Thu, Jan 28, 2010 at 2:50 AM, Matt Iavarone <matt.iavarone at gmail.com> wrote:
> On Tue, Jan 26, 2010 at 6:22 AM, Gustavo Schroeder <gutosch at gmail.com> wrote:
>> Hi,
>>
>> I've always used iproute2 with a fixed IP, which makes things easy to
>> get the address in order to insert it into other dynamic tables. My
>> issue is that now, the IP is going to be dynamic; one will use
>> dhclient to get the IP but I'm puzzled on how to insert it into
>> dynamic tables using redhat features.
>> Here's the scenario:
>> - interface A receives dynamic IP using dhclient
>> - once iface A is up, one needs to get the current IP address an push
>> it into a dynamic table
>>
>> This is perfectly achievable using a post-up interface script, since
>> the iface is up and has an IP I can easily get the addr. Is such a
>> feature supported in redhat using an /etc/sysconfig/route-ethX or
>> rule-ethX approach?
>>
>> Regards
>> -Gustavo
>>
>> --
>> redhat-sysadmin-list mailing list
>> redhat-sysadmin-list at redhat.com
>> https://www.redhat.com/mailman/listinfo/redhat-sysadmin-list
>>
>
> With iptables2, you are setting the new default route by subnet, not
> by specific IP address, correct?  So as long as you are getting a DHCP
> address from one subnet only, then you can do something along the
> lines of the following:
>
> #echo "255 newroute" >> /etc/iproute2/rt_tables
> #ip route add 192.168.1.0/24 dev eth1 src 192.168.2.10 table newroute
> #ip rule add from 192.168.2.10/24 table admin

Yes, default route is being done by subnet. I'm familiar with the
example above, and it is exactly what I've been doing when the IP is
static. I know the IP so one just needs to add into the correct
route-ethX file under /etc/sysconfig/network-scripts.
But for this case the interface must use a dynamic IP. So how am I
going to know the correct ip (to use in src field) in order to add
into route/rule-ethX?
I was thinking that, once dhclient gets the ip addr it stores into a
variable, and perhaps it would be possible to use this var in the src
field of the route/rule-ethX file.
I'm trying to digg this var from the sysconfig files but no luck so far.
Any clue?

-Gustavo

>
> I don't have my documentation handy, but it should look something like
> that.  Once you verify that it is correct, you can create the route
> and rule scripts in ../network-scripts.  It's pretty much the same
> commands, but you would remove "ip rule add" and "ip route add" (check
> the ifup scripts to be sure though).
>
> -Matt
>
> --
> redhat-sysadmin-list mailing list
> redhat-sysadmin-list at redhat.com
> https://www.redhat.com/mailman/listinfo/redhat-sysadmin-list
>




More information about the redhat-sysadmin-list mailing list