Operating System - Linux
1827869 Members
872 Online
109969 Solutions
New Discussion

how to change subnet mask

 
SOLVED
Go to solution
emily_3
Frequent Advisor

how to change subnet mask

Hi,
I use the following command to check my linux server. When the destination is default (0.0.0.0), I want to change the Genmask to be 255.255.224.0 instead of 0.0.0.0.
Can you advice me which file I should change? And I was confused that it seems the following three line is configured in different files.

#netstat -rn
Kernel IP routing table
Destination Gateway Genmask Iface
15.104.96.0 0.0.0.0 255.255.224.0 eth1
127.0.0.0 0.0.0.0 255.0.0.0 lo
0.0.0.0 15.104.96.1 0.0.0.0 eth1
13 REPLIES 13
Alexander Chuzhoy
Honored Contributor

Re: how to change subnet mask

these lines are your routing table.

To change your subnet mask edit the file
/etc/sysconfig-network-scripts/ifcfg-eth?

where ? can be 0,1 etc

to define permanent route edit the file (it doesn't exist by default
/etc/sysconfig/static-routes

Stuart Browne
Honored Contributor

Re: how to change subnet mask

I also think you're mildly confused as to what a default route is all about!

The default route is where the packet goes if it doesn't know where else to go.

It's the last-resort route.

In order for this to work, it can't be a match for *anything*, thus why it's a 0 bit subnet mask.

If you have a subnet you want to route, that isn't on the local net (15.104.96.0/255.255.224.0), then you need t add a static route (as Alexander has pointed out).

One long-haired git at your service...
emily_3
Frequent Advisor

Re: how to change subnet mask

hi,

But my routing table has two lines for eth1, does that mean I need to add both of them to the same file /etc/sysconf/network-scrips/eth1?

Alexander Chuzhoy
Honored Contributor

Re: how to change subnet mask

the only rules for route you need to add are those that aren't there by default and you wish to define them.
The 0.0.0.0 route may be configured from GATEWAY=x.x.x.x
in
/etc/sysconfig/network
or
/etc/sysconfig/network-scripts/ifcfg-eth1
emily_3
Frequent Advisor

Re: how to change subnet mask

Thanks for your advice.
I am trying to add the subnet mask to /etc/sysconfig/network and restarting and waiting for the result.

I would like to know what's the difference between the following directory files:
/etc/sysconfig/network
/etc/sysconfig/networking/
/etc/sysconfig/network-scripts/
emily_3
Frequent Advisor

Re: how to change subnet mask

The system boot up.

right now my /etc/sysconfig/network looks like this:
NETWORKING=yes
HOSTNAME=ssrvr260
GATEWAY=15.104.96.1
NETMASK=255.255.224.0
GATEWAYDEV=eth1

But the subnet mask is still 0.0.0.0 for Gateway 15.104.96.1? why?
Alexander Chuzhoy
Honored Contributor
Solution

Re: how to change subnet mask

you don't have to restart the whole system to see the result.
it's enough to restart the network service:
service network restart
/etc/sysconfig/network
is the file with system wide definitions:
like the hostname of the station, the default gateway.
/etc/sysconfig/network-scripts
directory holds the definitions for each network adapter and whatever is assigned with it.
Ip address,type, permission to disable etc


P.S.Please assign points if useful
Alexander Chuzhoy
Honored Contributor

Re: how to change subnet mask

because the file /etc/sysconfig/netowrk holds the line GATEWAY=15.104.96.1
It makes the address 15.104.96.1 as default gateway for 0.0.0.0
emily_3
Frequent Advisor

Re: how to change subnet mask


i will assign the rest of the answers finally.

Do you mean that if I use the default gateway the subnetmask must be 0.0.0.0 and can not be changed?
Does the netmask has any problem for this system? since I am trying to use "spdash" comunicate with another server existing in the same subnet, but it failed. while I could ping this server. Don't know why?
Alexander Chuzhoy
Honored Contributor

Re: how to change subnet mask

that's why it's "default" gateway.

to add route to a certain network try this command:
route add -net 10.10.0.0 netmask 255.255.0.0 gw 192.168.0.1

The addresses here are just examples of course.This means to add a route to a subnet 10.10.0.0 with subnet mask 255.255.0.0 via gateway 192.168.0.1

If you can ping some server -that means that you already can communicate with it.
So maybe you trying to access some service on that server that's blocked or unavailable.
emily_3
Frequent Advisor

Re: how to change subnet mask

I found the issue due to the lo subnet mask is not correct. Thanks.

Please advice why the outside communication still need the lo setting?

Thanks.
Alexander Chuzhoy
Honored Contributor

Re: how to change subnet mask

Generally it doesn't -what did you change?
Colin Topliss
Esteemed Contributor

Re: how to change subnet mask

lo is your loopback device. If you get this screwed up, networking will experience problems:

ifcfg-lo has:

DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0

You host file should have (if its the default) the following lines:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost

So, in having a problem with the loopback configuration you would have seen problems with some network services.

Col.