Two or more network interfaces: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 18: | Line 18: | ||
# | # | ||
#1 inr.ruhep | #1 inr.ruhep | ||
1 | 1 rt1</pre> | ||
* Add | * Add | ||
<pre> | <pre> | ||
if ! /sbin/ip route list table | if ! /sbin/ip route list table rt1 | grep "^default via g.g.g.g dev eth1" 1> /dev/null ; then | ||
/sbin/ip route add n.n.n.n/22 dev eth1 proto kernel src a.a.a.a table | /sbin/ip route add n.n.n.n/22 dev eth1 proto kernel src a.a.a.a table rt1 | ||
/sbin/ip route add default via g.g.g.g dev eth1 metric 1 table | /sbin/ip route add default via g.g.g.g dev eth1 metric 1 table rt1 | ||
fi</pre> | fi</pre> | ||
to the end of the function <code>gateway_up</code> in <code>/etc/rc.d/rc.inet1</code> | to the end of the function <code>gateway_up</code> in <code>/etc/rc.d/rc.inet1</code> | ||
| Line 30: | Line 30: | ||
* # /etc/rc.d/rc.inet1 restart | * # /etc/rc.d/rc.inet1 restart | ||
* $ /sbin/ip route list table | * $ /sbin/ip route list table rt1 | ||
* Add | * Add | ||
<pre> | <pre> | ||
if ! /usr/sbin/ip rule show | grep "a.a.a.a lookup | if ! /usr/sbin/ip rule show | grep "a.a.a.a lookup rt1" 1> /dev/null ; then | ||
/usr/sbin/ip rule add from a.a.a.a/32 table | /usr/sbin/ip rule add from a.a.a.a/32 table rt1 | ||
/usr/sbin/ip rule add to a.a.a.a/32 table | /usr/sbin/ip rule add to a.a.a.a/32 table rt1 | ||
fi | fi | ||
</pre>to <code>/etc/rc.d/rc.firewall</code> | </pre>to <code>/etc/rc.d/rc.firewall</code> | ||
Revision as of 17:06, 23 August 2021
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 network n.n.n.n/22 and gateway g.g.g.g.
- Add
eth1data 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 rt1
- Add
if ! /sbin/ip route list table rt1 | grep "^default via g.g.g.g dev eth1" 1> /dev/null ; then /sbin/ip route add n.n.n.n/22 dev eth1 proto kernel src a.a.a.a table rt1 /sbin/ip route add default via g.g.g.g dev eth1 metric 1 table rt1 fi
to the end of the function gateway_up in /etc/rc.d/rc.inet1
- # /etc/rc.d/rc.inet1 restart
- $ /sbin/ip route list table rt1
- Add
if ! /usr/sbin/ip rule show | grep "a.a.a.a lookup rt1" 1> /dev/null ; then /usr/sbin/ip rule add from a.a.a.a/32 table rt1 /usr/sbin/ip rule add to a.a.a.a/32 table rt1 fi
to /etc/rc.d/rc.firewall
- # /etc/rc.d/rc.firewall restart
- $ /sbin/ip rule show