두 개의 인터페이스가 있는 Crunchbang VM이 있고, eth0
각 eth1
인터페이스는 OpenWRT VM( eth0
being 10.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
그러면 두 가지 경로가 있습니다.
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는 두 인터페이스를 통해 연결됩니다.
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':
그러나 Network Manager를 잃어버려야 할 것 같습니다. 그것이 왜 나쁜 생각인지 설명하거나 함정에 대해 경고할 수 있는 사람이 있다면 감사하겠습니다.
편집2
Network Manager 제거가 잘 진행되었습니다. 마지막 질문이 하나 있습니다. 부팅 시 구성을 로드하는 현재 표준 방법은 무엇입니까?
답변1
첫째, 문제에 대한 해결책이 좋습니다. 둘째, OS에 따라 다릅니다. Crunchbag은 데비안 기반이므로 이 솔루션이 작업을 수행할 수 있습니다.
https://serverfault.com/questions/487939/permanently-adding-source-policy-routing-rules
RHEL 기반 시스템에서는 <ifname>-rule
및 <ifname>-route
.