Dynamic interface using iproute2

Matt Iavarone matt.iavarone at gmail.com
Thu Jan 28 04:50:16 UTC 2010


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

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




More information about the redhat-sysadmin-list mailing list