How do I route internet traffic over my second IP address?
Hi,
My ISP has given me 3 IP addresses to use for the internet (76.148.200.3, 76.148.200.4 and 76.148.200.5). If I do a "wget whatismyip.com" or netcat into another server, I am appearing as 76.148.200.3. How do I change my route (command line) in linux to route internet traffic through 76.148.200.5? Code:
# This file describes the network interfaces available on your system Here's the into if I type "ip route": Code:
root@ubuntu:~# ip route |
The easy way would be to configure eth0 as 76.148.200.5 and eth0:1
as 76.148.200.3. |
But I want the hard way or I learn nothing :)
|
lol. I guess you get nothing from me!
|
Try to delete default and add new one:
ip route add default via 76.148.200.1 dev eth0:1 |
Quote:
I tried that but it shows in routing table as eth0 (not eth0:1) and still goes through first one. |
Quote:
|
Ok guess I'll have to do that, thanks.
|
Routing determines where packets go to. If all your IP addresses have the same destination gateway, then the routing will be the same no matter which you want to use as your "source address".
The "source address" is your address on packets you originate. For incoming connections (e.g. if you are running a server) the "source address" for the return packets will be the one the connection was established with. But for packets you originate (make a connection to somewhere on the internet) then a decision has to be made. That decision can be made by the application when it sets up the sockets. Most applications don't do that. So then the decision is made by the network stack. When that happens, the decision is the first IP address matching the specified address family, for an interface the outgoing route will work on. It will probably be the first usable interface if the applicable route is not interface specific. So use carltm's easy way ... it's THE WAY. If you really want a hard way, then write a program in assembly language to write the /etc/network/interfaces file directly ... that should be plenty hard enough :-) |
I worked out one way to do it...
Code:
iptables -t nat -A POSTROUTING -j SNAT --to 76.148.200.5 |
All times are GMT -5. The time now is 04:33 PM. |