
2つのインターフェイスを持つCrunchbang VMがあり、eth0
各eth1
インターフェイスはOpenWRT VM(eth0
being10.232.64.20
と
eth1
being 10.232.65.20
)に接続されています。ネットワーク管理者とDHCPを使用しています。私の全体的な目標は、複数の接続を持ってssh
これをifenslave
。
デフォルトではeth1
(何らかの理由で)デフォルトゲートウェイは次のとおりです。
user@crunchbang:~$ ip ro
default via 10.232.65.1 dev eth1 proto static
10.232.64.0/24 dev eth0 proto kernel scope link src 10.232.64.20
10.232.65.0/24 dev eth1 proto kernel scope link src 10.232.65.20
パスを追加しましたeth0
。
user@crunchbang:~$ sudo ip route add default via 10.232.64.1 dev eth0 proto static metric 1
これには2つのパスがあります。
user@crunchbang:~$ ip ro
default via 10.232.65.1 dev eth1 proto static
default via 10.232.64.1 dev eth0 proto static metric 1
10.232.64.0/24 dev eth0 proto kernel scope link src 10.232.64.20
10.232.65.0/24 dev eth1 proto kernel scope link src 10.232.65.20
ただし、次のssh
方法でしか行えませんeth1
。
user@crunchbang:~$ ssh -b 10.232.64.20 [email protected]
ssh: connect to host 1.2.3.4 port 22: Connection timed out
user@crunchbang:~$ ssh -b 10.232.65.20 [email protected]
Enter passphrase for key '/home/user/.ssh/id_rsa':
eth0
インジケータを変更した後、以下が発生しました。
user@crunchbang:~$ ip ro
default via 10.232.64.1 dev eth0 proto static metric 1
default via 10.232.65.1 dev eth1 proto static metric 2
10.232.64.0/24 dev eth0 proto kernel scope link src 10.232.64.20
10.232.65.0/24 dev eth1 proto kernel scope link src 10.232.65.20
今ssh
唯一の出口は次のとおりですeth0
。
user@crunchbang:~$ ssh -b 10.232.64.20 [email protected]
Enter passphrase for key '/home/user/.ssh/id_rsa':
user@crunchbang:~$ ssh -b 10.232.65.20 [email protected]
ssh: connect to host 1.2.3.4 port 22: Connection timed out
ssh
より高いメトリックを使用するインターフェイスを強制的に使用するにはどうすればよいですか?
編集する
構成を実装してテストしました。4.2。マルチアップリンク/プロバイダーによるルーティングLinux高度なルーティングとトラフィック制御HOWTOの一部です。設定が簡単でエラーも発生しなかったので、最小限の説明と一緒にコードと結果のみを表示します。
root@crunchbang:~# ip route add 10.232.64.0/24 dev eth0 src 10.232.64.20 table T0
root@crunchbang:~# ip route add default via 10.232.64.1 table T0
root@crunchbang:~# ip route add 10.232.65.0/24 dev eth1 src 10.232.65.20 table T1
root@crunchbang:~# ip route add default via 10.232.65.1 table T1
root@crunchbang:~# ip route flush table main
root@crunchbang:~# ip route add 10.232.64.0/24 dev eth0 src 10.232.64.20
root@crunchbang:~# ip route add 10.232.65.0/24 dev eth1 src 10.232.65.20
root@crunchbang:~# ip rule add from 10.232.64.20 table T0
root@crunchbang:~# ip rule add from 10.232.65.20 table T1
root@crunchbang:~# ip route add default scope global nexthop via 10.232.64.1 dev eth0 weight 1 nexthop via 10.232.65.1 dev eth1 weight 1
生成されたルーティングテーブルは次のとおりです。
root@crunchbang:~# ip route show table T0
default via 10.232.64.1 dev eth0
10.232.64.0/24 dev eth0 scope link src 10.232.64.20
root@crunchbang:~# ip route show table T1
default via 10.232.65.1 dev eth1
10.232.65.0/24 dev eth1 scope link src 10.232.65.20
root@crunchbang:~# ip ro
default
nexthop via 10.232.64.1 dev eth0 weight 1
nexthop via 10.232.65.1 dev eth1 weight 1
10.232.64.0/24 dev eth0 scope link src 10.232.64.20
10.232.65.0/24 dev eth1 scope link src 10.232.65.20
この構成では、ssh は 2 つのインターフェースを介して接続されます。
user@crunchbang:~$ ssh -b 10.232.64.20 [email protected]
Enter passphrase for key '/home/user/.ssh/id_rsa':
user@crunchbang:~$ ssh -b 10.232.65.20 [email protected]
Enter passphrase for key '/home/user/.ssh/id_rsa':
しかし、ネットワーク管理者を失う必要があるようです。これがなぜ悪い考えなのか説明したり、落とし穴について警告できる人がいたら、感謝します。
編集2
ネットワーク管理者の削除が正常に行われました。最後の質問があります。起動時に設定をロードする現在の標準的な方法は何ですか?
答え1
まず、問題に対するあなたの解決策は素晴らしいです。第二に、オペレーティングシステムによって異なります。 CrunchbagはDebianに基づいているため、このソリューションはそれを行います。
https://serverfault.com/questions/487939/permanently-adding-source-policy-routing-rules
RHELベースのシステムでは、<ifname>-rule
およびを追加することもできます<ifname>-route
。