Multiple IPs and Gateway

Taking care of your Linux box.
Post Reply
ather_36
Naik
Posts: 97
Joined: Thu Jul 31, 2003 11:38 am
Location: karachi
Contact:

Multiple IPs and Gateway

Post by ather_36 »

Salam to all,
How can we define Multiple IPs and Gateway IPs to a Single Ethernet card.Suppose I have two different subnet IPs Address with Gateway.So please Kindly let me the command to define the multiple IPs and Gateway.
Suppose I have Two Different IPs:-
IP:192.168.1.1 Subnet Mask:255.255.255.0 Gateway 192.168.1.10

IP:202.251.150.5 Subnet Mask 255.255.255.0 Gateway 202.251.150.1

Plz help me
Thanks & Regards
Athar Hussain
LinuxFreaK
Site Admin
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
Location: Karachi
Contact:

Re:

Post by LinuxFreaK »

Dear ather_36,
Salam,

Route command will help you. You must read the manual of route command.

# man route
# route add -net 192.168.1.1 netmask 255.255.255.0 gw 192.168.1.10
# route add -net 202.251.150.5 netmask 255.255.255.0 gw 202.251.150.1


P.S: I do not ask you this publicly but i have no other choice, i am still waiting for you to return my Book. When i will get my Book back ?

Best Regards.
Farrukh Ahmed
sakimustafa
Lance Naik
Posts: 41
Joined: Sat Jan 13, 2007 1:36 pm
Location: Bangladesh
Contact:

Post by sakimustafa »

I did it in this way :
route add -net 10.0.40.0 netmask 255.255.255.0 dev eth1
route add -net 192.168.100.0 netmask 255.255.255.0 dev eth1
Best Regards,
SAKI
8801712764543
LinuxFreaK
Site Admin
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
Location: Karachi
Contact:

Re:

Post by LinuxFreaK »

Dear sakimustafa,
Salam,
sakimustafa wrote:I did it in this way :
route add -net 10.0.40.0 netmask 255.255.255.0 dev eth1
route add -net 192.168.100.0 netmask 255.255.255.0 dev eth1
What is the problem now ?

Best Regards.
Farrukh Ahmed
abdul_mateen
Battalion Havaldaar Major
Posts: 267
Joined: Tue Nov 18, 2003 10:28 am
Location: Rampuria Mansion
Contact:

Post by abdul_mateen »

Salam,
QOUTES
"""How can we define Multiple IPs and Gateway IPs to a Single Ethernet card.Suppose I have two different subnet IPs Address with Gateway.So please Kindly let me the command to define the multiple IPs and Gateway.
Suppose I have Two Different IPs:-
IP:192.168.1.1 Subnet Mask:255.255.255.0 Gateway 192.168.1.10

IP:202.251.150.5 Subnet Mask 255.255.255.0 Gateway 202.251.150.1"""

How can one single ethernet be on two different subnets.Do you have the multiport ethernet.Or If you can anyways define it you canot use multiple routers at the sametime.

Regards
Abdul Mateen.
Abdul Mateen,
Google Android Developer & Linux Administrator
Addictive Mobility,CA
www.addictivemobility.com.
LinuxFreaK
Site Admin
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
Location: Karachi
Contact:

Re:

Post by LinuxFreaK »

Dear abdul_mateen,
Salam,

I believe you should read the manuals. I have not done this before so i can not tell you exactly.

# man ifconfig
# man route
# man ip


Best Regards.
Farrukh Ahmed
Zaheer
Battalion Havaldaar Major
Posts: 286
Joined: Fri Oct 17, 2003 12:15 am
Location: Karachi
Contact:

Post by Zaheer »

You can achieve this task by giving some commands through ifconfig.I think you are asking for ipaliasing.Suppose you have a ethernet card eth0 and you want two ip's for this.you can do it with the following command:

ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up

and you can give the other ip for this ethernet card like this

ifconfig eth0:0 192.168.0.2 netmask 255.255.255.0 up

Check this link also :

Multiple IP addresses on a single NIC
Good Judgement comes from Experience and Experience comes from bad Judgement!!
The more I know, the more I realize I don't know!?
The easiest way to find out is to try Out!!!

Registered Linux user #333501
Post Reply