Related Items  

Linux and Windows IT Support  

dedicated-technology-experts

Windows, Apple and Linux IT support and services.

For Software and Web Development.

re: how to define route

PrintE-mail
@Umar: I'm not sure how you would do that with DHCP, you'll need a way to get an IP address in your config. You can try using variables: EXTIP, EXTMASK, etc. I assume that eth0 is your EXTERNAL card and eth1 is your INTERNAL card: In /etc/iproute2/rt_tables, add those two at the bottom: # # reserved values # 255 local 254 main 253 default 0 unspec # # local # #1 inr.ruhep 1 first 2 second then, in /etc/rc.local add the following (before exit 0): EXTIP="`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'`" EXTMASK="`/sbin/ifconfig eth0 | grep 'mask' | awk '{print $4}' | sed -e 's/.*://'`" EXTNET="`/sbin/route -n | grep 'eth0' | awk '{print $1}' | sed -e 's/\0\.\0\.0\.0//'`" EXTGW="`/sbin/route -n | grep 'eth0' | awk '{print $2}' | sed -e 's/\0\.\0\.0\.0//'`" ip route add $EXTNET/$EXTMASK dev eth0 src $EXTIP table first ip route add default via $EXTGW table first ip route add 10.64.99.0/24 dev eth1 src 10.64.99.11 table second ip route add default via 10.64.99.1 table second ip rule add from $EXTIP table first ip rule add from 10.64.99.11 table second It should work, in theory. (I haven't tested it with variables, I use static IPs in all my setups). If that doesn't work, you'll have to manually replace the variables with IPs. This will give you 2 routes, with access to both external and internal networks.
   
Copyright © 1999 - 2025 Virtual Helpme | Techical Support and Maintenance | Original Template: Allrounder