Two or more network interfaces
Suppose that we have a system with already configured network interface ethX and we want to add an ip address a.a.a.a with gateway g.g.g.g.
- Add the address with the subnet prefix length to
/etc/rc.d/rc.inet1.conf:
IPADDRS[X]="... a.a.a.a/aa"
- Add a routing table to
/etc/iproute2/rt_tables:
# # reserved values # 255 local 254 main 253 default 0 unspec # # local # #1 inr.ruhep 2 rt2
- Add
if ! /sbin/ip -4 route show table rt2 | grep -wq default; then debug_log "/sbin/ip -4 route add default via g.g.g.g table rt2" /sbin/ip -4 route add default via g.g.g.g table rt2 fi if ! /sbin/ip -4 rule show | grep "lookup rt2" 1> /dev/null ; then debug_log "/sbin/ip -4 rule add from a.a.a.a table rt2" /sbin/ip -4 rule add from a.a.a.a table rt2 fi
to the end of IPv4 section of the function gateway_up in /etc/rc.d/rc.inet1
- Add
if /sbin/ip -4 route show table rt2 | grep -wq default; then debug_log "/sbin/ip -4 route del default table rt2" /sbin/ip -4 route del default table rt2 fi if /sbin/ip -4 rule show | grep "lookup rt2" 1> /dev/null ; then debug_log "/sbin/ip -4 rule del lookup rt2" /sbin/ip -4 rule del lookup rt2 fi
to the end of IPv4 section of the function gateway_down in /etc/rc.d/rc.inet1
- # /etc/rc.d/rc.inet1 restart