Как проверить:
Suppose you have one or more network interfaces, and they have one or more assigned IP addresses, also called aliases. If you need to find out which IP address and interface will be used as a default "source” by your Linux box, you need to execute the following: view source print?
ip route get 8.8.8.8
This, of course, assumes that 8.8.8.8 is not directly connected on your networks somehow. Since this is one of the Public Name Servers of Google, I think it is safe to assume so. A sample output of the ip command follows: view source print?
8.8.8.8 via 10.0.2.2 dev eth0 src 10.0.2.15 cache
Как поменять:
If you setup an IP aliases (e.g., eth0:0, eth0:1) on a single NIC, by default the primary IP assigned to the NIC (eth0) will be used as the source IP for all outbound traffic. Where: eth0:0 - 172.16.0.10 external host - xxx.xxx.xxx.xxx external net - xxx.xxx.xxx.x/xx Specify what IP should be used for outbound traffic on a specific host:
# route add -host xxx.xxx.xxx.xxx dev eth0:0 All traffic destined to host xxx.xxx.xxx.xxx will be routed to eth0:0, thus the outgoing IP will be 172.16.0.10.
Specify what IP should be used for outbound traffic on a specific network:
# route add -net xxx.xxx.xxx.x/xx dev eth0:0
чтобы сделать изменения постоянными (после перезагрузки), нужно еще добавить в файл
/etc/sysconfig/network-scripts/route-eth0 (eth1, eth2 - по обстоятельствам)
строку
xxx.xxx.xxx.xxx/32 via yyy.yyy.yyy.yyy dev eth0
где xxx.xxx.xxx.xxx - IP адрес назначения, а yyy.yyy.yyy.yyy - маршрутизатор для eth0
|