LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Using Linux as Router for 2 IPs (https://www.linuxquestions.org/questions/linux-networking-3/using-linux-as-router-for-2-ips-26013/)

gofauna 07-17-2002 06:46 PM

Using Linux as Router for 2 IPs
 
Hi everyone, this is my brief situation:

I'm currently running Mandrake 8.2 and I'm a total newb. I got IP Masquerade working for one of my connection. However, since my ADSL can automatically assign 2 IP addresses (2 WAN IPs), I was wondering if I can tell my Linux box to grab those 2 IPs (it's okay if I need extra NICs). What I want is to have my windows clients (5 of them actually) to simultaneously share these 2 IPs accordingly. That means, I want to have Linux to use (or try to use) a different IP for different computers. For example, if only 2 windows clients are on, they will each use a different IP to do the routing. That way, I will be able to play games such as StarCraft (I know it's old school, but whatever = ) with each other. Will this require the Windows clients to use DHCP to grab IPs from the Linux server, such as 192.168.1.X, where if X is odd, it uses WAN IP #1 and if X is even it uses WAN IP #2?

Also, is it possible to have conenctions from the outside world be automatically forwarded into a Windows client? Starcraft uses port 6112 (hence, now I can join games but cannot have others join me behind the Linux routing) that way I can create games or servers on my client computers. I know that I still cannot have all 5 clients creating a game at the same time, but I was wondering if the windows clients could run a telnet executable telling the Linux server to route the port 6112 from WAN IP #1 to that specific windows client? And vice versa if it uses WaN IP #2??

Whew, hopefully you guys can understand what I want. I have difficulty explaining it = )

sarin 07-17-2002 09:39 PM

Well, You can grab two ips and do all that you said here.
But I don't know the exact steps. "iptables" is the stuff
that you should go for. ( It is a firewall which I think
should be a part of Mandrake. -- It is there in latest
kernel. ). Here is a good guide on that.

http://people.unix-fu.org/andreasson...-tutorial.html

--Sarin
PS: To grab 2 ips you may not need this. Just make 2 interfaces
and keep the bootproto as dhcp. I think that should work.

turnip 07-17-2002 10:14 PM

The easiest way to do this w/o a dhcp server is this

in linux you already have one ip assigned to ppp0 i assume. so do this

ifconfig ppp0:1 <otherip> up

route add -host <publicip> dev ppp0:1

now ppp0 has 2 addresses only one is on ppp0:1 so then you do

iptables -t nat -A PREROUTING -p tcp -d <otherip> --dport 1:65000 -j DNAT --to internalip

iptables -t nat -A PREROUTING -p udp -d <otherip> --dport 1:65000 -j DNAT --to internalip

where internal ip is the private assigned to your machine. that should forward all traffic to the other public ip to a private inside the lan
so then we just need masq rules.

iptables -t nat -A POSTROUTING -s <localip> -d <publicip> -j MASQUERADE

then iptables -A OUTPUT -s <publicip> -j ACCEPT

this might need some editing here, its been awhile since ive had to do this, but it's possible. you're going to have to play with default routes on the windows machine as well.

and like i said setting up a dhcp scope for the one ip would work too.

turnip 07-17-2002 10:38 PM

the masquerade rule is wrong, clearly. Im working on it though.

gofauna 07-18-2002 01:26 AM

how would I go about creating a eth1 or eth2 based on the same ethernet card? I want to have LAN IPs for eth1. Currently it is set up to be eth0:0 alias.

sarin 07-18-2002 01:33 AM

I don't think you can create eth1, eth2 etc on the same
card. You can anyway have eth0:0, eth0:1 etc.
( Even if it does, if you are looking for a good firewall/
gateway, it won't be a good idea.)
--Sarin.


All times are GMT -5. The time now is 08:00 PM.