We help IT Professionals succeed at work.

Trouble Creating a Routing Table

kara334
kara334 asked
on
Medium Priority
570 Views
Last Modified: 2012-06-22
Hi,

I am trying to complete an assignment for a class about subnets and routing tables. I am using the terninal shell on my Mac.

I assigned the IP address 192.168.3.1 to en0. (My teacher's instructions were to assign the address to eth0, but apparently my Mac doesn't use that interface).

Next I was told to test various network addresses and netmasks using the route command. I tried for several that should be legal, but got the error msg "illegal option -a".

Here are a couple of combinations I tried that I think should be legal:

network address: 209.220.186.96 subnet 255.255.255.224

network address: 209.220.186.240 subnet 255.255.255.240

I used the follow command to try to add them to the routing table"

route -add -net 209.220.186.96 netmask 255.255.255.224

etc.

Is there anyone that can help me and tell me what I'm doing wrong?


Thanks.


Kara

Comment
Watch Question

Try this:

route add -net 209.220.186.96/27 gw <destination_gateway> en0

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Gabriel OrozcoSolution Architect

Commented:
ir, if that does not work, use

route add -net 209.220.186.96 netmask 209.220.186.240 gw <destination_gateway> dev en0

problem is, you need an ip address to be your gateway to the new network. maybe it's your default gateway anyways? but you need to tell the route command that ip in order to make it work.

Author

Commented:
Well, that sounds like it will work. But I don't know my gateway or default gateway. When I do ifconfig, I don't see it. Can you help me figure out my gateway? Thank you.
Gabriel OrozcoSolution Architect

Commented:
netstat -nr

or

route -n

should show it to you.

Author

Commented:
Thank you again. I think I found the default gateway - 192.168.1.1. But obviously I'm doing something else wrong. (see the code below). I made a few typos along the way. But even when I think I typed everything correctly,  I'm still getting an error.


Karas-Computer:~ root# netstat -nr
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
default            192.168.1.1        UGSc        4        5    en0
127                127.0.0.1          UCS         0        0    lo0
127.0.0.1          127.0.0.1          UH         10     1798    lo0
169.254            link#4             UCS         0        0    en0
192.168.1          link#4             UCS         1        0    en0
192.168.1.1        link#4             UHLW        3        0    en0
192.168.1.101      127.0.0.1          UHS         0        0    lo0
192.168.3          link#4             UC          0        0    en0

Internet6:
Destination                             Gateway                         Flags      Netif Expire
::1                                     ::1                             UH          lo0
fe80::%lo0/64                           fe80::1%lo0                     Uc          lo0
fe80::1%lo0                             link#1                          UHL         lo0
fe80::%en0/64                           link#4                          UC          en0
fe80::20d:93ff:fe76:ce28%en0            0:d:93:76:ce:28                 UHL         lo0
ff01::/32                               ::1                             U           lo0
ff02::/32                               ::1                             UC          lo0
ff02::/32                               link#4                          UC          en0
Karas-Computer:~ root# route add -net 209.220.186.96 netmask 255.255.255.96 gw 192.168.3 dev en0
route: bad address: netmask
Karas-Computer:~ root# route add -net 209.220.186.96 netmask 255.255.255.96 gw 192.168.1.1 dev en0
route: bad address: netmask
Karas-Computer:~ root# route add -net 209.220.186.96 netmask 255.255.255.96 gw 192.168.1.1 dev en0
route: bad address: netmask
Karas-Computer:~ root# route add -net 209.220.186.96 netmask 255.255.255.224 gw 192.168.3 dev en0
route: bad address: netmask
Karas-Computer:~ root# route add -net 209.220.186.96 netmask 255.255.255.224 gw 192.168.1.1 dev en0
route: bad address: netmask
Karas-Computer:~ root# route add -net 209.220.186.240 netmask 255.255.255.240 gw192.168.1.1 dev en0
route: bad address: netmask
Karas-Computer:~ root#
Karas-Computer:~ root#

Commented:
Hi kara334,

Why don't you try
route add -net 209.220.186.240/24 gw192.168.1.1 dev en0
just to see if that works and that change 24 to whatever you need.

Hope that will help.

Miro
Solution Architect
Commented:
yes. it is saying the "netmask" part is not part of the route package in your Macintosh...

try to use

 route add -net 209.220.186.240/19 gw192.168.1.1 dev en0

Author

Commented:
I ended up dropping this class and forgot I had a question open. Sorry for the late points.

Kara
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.