You are not logged in.

#1 2007-08-23 19:39:07

Hwoarang
Member
From: Greece
Registered: 2007-08-23
Posts: 8
Website

2 IPs and static routes

Hello

Im kinda newbie here. My PC is running Arch Linux. The PC is member of two networks. So I need to find a way to add two IPs and several static routes on every network

For example

I want to add the 192.168.1.2 and 10.140.6.90 as IPs and 10.0.0.0/8 gw 10.140.6.1 as a static route

Can you tell me how to do that?

Thanks a lot

Offline

#2 2007-08-24 01:49:01

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: 2 IPs and static routes

sure. Just add them to your rc.conf.

Are they separate NICs, or one NIC with multiple IPs?


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#3 2007-08-24 11:49:03

Hwoarang
Member
From: Greece
Registered: 2007-08-23
Posts: 8
Website

Re: 2 IPs and static routes

There is on the same NIC with multiple IPs and static routes

this is my current rc.conf conserning network

lo="lo 127.0.0.1"
eth0="eth0 192.168.2.7 netmask 255.255.0.0 broadcast 192.168.2.255"
gateway="default gw 192.168.2.1"
ROUTES=(gateway)

So how should I add the second IP and the static route? sad

Last edited by Hwoarang (2007-08-24 11:49:37)

Offline

#4 2007-08-30 00:59:32

hungsonbk
Member
Registered: 2007-05-26
Posts: 105
Website

Re: 2 IPs and static routes

I don't know if you have two NICs or one NIC but you can write a script or put your commands in rc.local script.
If you have one NIC you can use the following commands:
          ifconfig eth0 192.168.1.2 netmask 255.255.255.0
          ifconfig eth0:1 10.140.6.90 netmask 255.255.255.0

To Add a static route:
          route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.140.6.1

To Add a default route
          route add default gw ip.address.of.gateway

If your have two NICs, the command is slightly different:
          ifconfig eth0 192.168.1.2 netmask 255.255.255.0
          ifconfig eth1 10.140.6.90 netmask 255.255.255.0

and the static routes are added the same.

Cheers.

Offline

#5 2007-08-30 13:50:44

Hwoarang
Member
From: Greece
Registered: 2007-08-23
Posts: 8
Website

Re: 2 IPs and static routes

Thank you very much

One last question. Is there a way to add them on rc.conf file instead of creating a script? Thanks

Offline

#6 2007-08-30 19:50:32

hungsonbk
Member
Registered: 2007-05-26
Posts: 105
Website

Re: 2 IPs and static routes

Hi Mate,
it is quite easy to put these commands in the rc.conf script because this script just uses the ifconfig and route command.
Here is what you need to do:

lo="lo 127.0.0.1"

eth0="eth0 192.168.1.2 netmask 255.255.255.0 broadcast 192.168.1.255"
eth1="eth0:1 10.140.6.90 netmask 255.255.255.0 broadcast 10.140.6.255"
INTERFACES=(lo eth0 eth1)

#TO add the static route and the default gateway:

static="-net 10.0.0.0 netmask 255.0.0.0 gw 10.140.6.1"
gateway="default gw 192.168.1.1"
ROUTES=(gateway static)

Hope this can help you.

Cheers.

Offline

#7 2007-08-30 22:37:09

Hwoarang
Member
From: Greece
Registered: 2007-08-23
Posts: 8
Website

Re: 2 IPs and static routes

Thanks mate for the help. Now works perfect .  smile smile smile smile smile

Offline

Board footer

Powered by FluxBB