Route all trafic for specific ip over specific network inter
I have a linux server that needs to get some routing. I‘m fairly new at this and i don‘t find any clear source on google.
The setup should be simple:
All traffic to a server on ip 192.168.72.20 should be sent over interface 3.
All other interfaces don‘t matter at the moment.
Here you have the output for route -n
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.72.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.72.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 192.168.72.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2 192.168.72.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3 192.168.72.0 0.0.0.0 255.255.255.0 U 0 0 0 eth4 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 0.0.0.0 192.168.72.12 0.0.0.0 UG 0 0 0 eth0
improve this question
asked Mar 29 ‘13 at 13:29
Frederiek
17811 gold badge11 silver badge55 bronze badges
1
Are you using the old fashioned ifconfig and route command or the modern ip commands? (old ones would be something like route add -host 192.168.72.20 GW eth3_ip) – Hennes
i don‘t know, i guess the old ones, how can i check that? – Frederiek
1 Answer
20
Try:
ip route add 192.168.72.20/32 dev eth3
improve this answer
answered Mar 29 ‘13 at 13:48
LawrenceC
62.2k1212 gold badges109109 silver badges189189 bronze badges
3
Just a note: to permanently keep this configuration make sure you add it to /etc/rc.local or your distro‘s equivalent. It won‘t persist between reboots. – LawrenceC
1
I tried this same format for mapping an IP to the wlan0 on Ubuntu 14.04 and got RTNETLINK answers: Invalid argument I had to remove the /** from the IP so I ended up with: sudo ip route add 192.168.50.15 dev wlan0 -- thought I‘d mention that in case anyone else ran into this issue. Thank you for your answer ultrasawblade, it was helpful. – mason81
3
Do not forget via <gateway_ip> if the target IP is not directly reachable! – calandoa
Route all trafic for specific ip over specific network interface
温馨提示: 本文由杰米博客推荐,转载请保留链接: https://www.jmwww.net/file/web/10269.html