Two or more network interfaces

From Notes to self
Revision as of 16:04, 19 August 2021 by Verbovet (talk | contribs)
Jump to navigation Jump to search

Based on the Thomas-Krenn-Wiki

Suppose that we have a system with already configured network interface eth0 and we want to add another interface eth1 with address a.a.a.a from the network n.n.n.n/22 and the gateway g.g.g.g.

  • Add eth1 data to /etc/rc.d/rc.inet1.conf. Do not change the gateway.
  • Add a routing table to /etc/iproute2/rt_tables:
#
# reserved values
#
255     local
254     main
253     default
0       unspec
#
# local
#
#1      inr.ruhep
1 rt2
  • Add
if ! /usr/sbin/ip route list table rt2 | grep "^default via g.g.g.g dev eth1" 1> /dev/null ; then
  /usr/sbin/ip route add n.n.n.n/22 dev eth1 proto kernel src a.a.a.a table rt2
  /usr/sbin/ip route add default via g.g.g.g dev eth1 metric 1 table rt2
fi

to the end of the function gateway_up in /etc/rc.d/rc.inet1