changing IP and gateway using 'ifconfig'

changing IP and gateway using 'ifconfig'

Post by Glitc » Thu, 22 Mar 2001 14:17:52



hi,

My school uses the 10.x.x.x block of private IPs for the lab. I use
192.168.x.x for my LAN.  I hav a laptop that I bring to school sometimes
and hook up to the network(temporarily taking a cable out of a lab PC
and putting it in my laptop and borrowing the IP of the PC as well)

THe problem is I can't get ifconfig to change both the IP and the netmask.

If i do:

ifconfig eth0 up address 10.0.108.154 netmask 255.0.0.0

it hangs and i hit Ctrl-C to get a prompt back. If I do an 'ifconfig'
the IP is back to using the original IP (192.168.x.x) but the netmask
changed to what it should be, 255.0.0.0.  Why won't both the IP and the
netmask change?

I've looked at the manpage but it didn't help, plus i don't think it's
right anyway. The syntax the man page shows is to pipe the IP at teh end.

I tried that by doing the following:

ifconfig eth0 up netmask 255.0.0.0 | address 10.0.108.154

well, that gave me a prompt back but when i checked with ifconfig the IP
STILL didnt change. Why the hell not?

thanks for any help
brandon

 
 
 

changing IP and gateway using 'ifconfig'

Post by Dean Thompso » Thu, 22 Mar 2001 14:28:29


Hi Brandon,

[...]

Quote:> The problem is I can't get ifconfig to change both the IP and the netmask.
> If i do:

> ifconfig eth0 up address 10.0.108.154 netmask 255.0.0.0

> it hangs and i hit Ctrl-C to get a prompt back. If I do an 'ifconfig'
> the IP is back to using the original IP (192.168.x.x) but the netmask
> changed to what it should be, 255.0.0.0.  Why won't both the IP and the
> netmask change?

Could it be a problem that you are not specifying the broadcast address as
well.  Therefore you would be using something like 10.0.108.154 as your IP
address, netmask of 255.0.0.0 but with a invalid broadcast address.

The best trick that I have seen to get around this problem is to create two
files with the network configuration for school and another for your home
LAN.  You could then write a quick script that goes through and actually
changes the symbolic links which could point to either the school or home
settings.  The script could lower the eth0 interface, flush the routing table,
then bring up the interface with the correct routing table in place.

It would just mean that you would have to boot into single user mode, issue
the instruction and then press CTRL-D to continue the boot if you want to
change the IP address at startup.

See ya

Dean Thompson

--
+____________________________+____________________________________________+

| Bach. Computing (Hons)     | ICQ     - 45191180                         |
| PhD Student                | Office  - <Off-Campus>                     |
| School Comp.Sci & Soft.Eng | Phone   - +61 3 9903 2787 (Gen. Office)    |
| MONASH (Caulfield Campus)  | Fax     - +61 3 9903 1077                  |
| Melbourne, Australia       |                                            |
+----------------------------+--------------------------------------------+

 
 
 

1. ping -g 'gateway-IP' 'host-IP' DOESN'T work!

Hello guys,

I have a machine with two interfaces, each connected to
a gateway. This two gateways are then connected to a common
network and I want to ping another router in that network over
the two interfaces.

Looks like this:
                        Gateway 1
                           ----
               ------------|  |------------
              | Subnet A   ----            |
            ----
Machine    |  |                Subnet C   Router
            ----
              | Subnet B   ----            |
               ------------|  |------------
                           ----
                        Gateway 2

Now if I type following on my machine it doesn't work:

ping -g 'IP in Subnet A of Gateway 1' 'Router-IP-address'

But if I do a ping (Defaultgateway is 'IP in Subnet A of Gateway 1'
(without -g) it works fine:

ping 'Router-IP-address'

Can someone give me a hint? Thanks in advance!

Cheers, Walter

2. loopback vs. symbolic links

3. VOIP gateway can't get the IP once the ASDL modem change the new IP

4. Porting my program from Windows

5. ifconfig eth1 change ip's

6. Strip libc

7. Will changing IP address affect 'rlogin'/'telnet'?

8. modeming in

9. how to change my server 's IP and GATEWAY

10. Secondary Gateway for Secondary Network Card using Secondary IP's

11. Two IP's / gateway's on one system?

12. Can't change 'coredumpsize' to 'unlimited'