LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Simple - Changing your network settings without rebooting??? (https://www.linuxquestions.org/questions/linux-newbie-8/simple-changing-your-network-settings-without-rebooting-506486/)

Exio 12-01-2006 05:22 AM

Simple - Changing your network settings without rebooting???
 
Hi,

I just started using Linux again. Its been a year and iv forgotten almost everything..

I remembered "netconfig" WOO but I have to reboot my box every time i make a change in it.

How do i get it to change with out rebooting.

P.S - I remembered "ifconfig" to WAHHOOO I’m a Linux Guru

Thanks

Nick (Linux Guru :D)

b0uncer 12-01-2006 05:33 AM

You shouldn't need to reboot after using netconfig; what you probably have to do is bring the interface(s) down and up (that's what happens during reboot anyway) when you make changes. Probably either one of these (I don't do much changes to my network settings, and I'm working on a non-Linux box atm, so just guessing):
Code:

ifconfg eth0 down
ifdown eth0

and then configure the settings you like and do either one of these:
Code:

ifconfig eth0 up
ifup eth0

That should work.

EDIT: you could also use ifconfig to change ip address etc. like
Code:

ifconfig eth0 down
ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up


Exio 12-01-2006 05:37 AM

I shall give this a go!! Thanks for the speedy Reply!

Nick

Exio 12-01-2006 05:55 AM

Just had a thought!!!

Im connecting using putty.

If i take my etho down this will disconect me?

I remember $$ command?

can i do

ifconfig eth0 down $$ ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up

then re-putty back in??

Nick

matthewg42 12-01-2006 06:22 AM

If eth0 is the interface over which your putty traffic is travelling, taking down that connecting will prevent further communication with the machine.

I think you mean &&, not $$. $$ means "the PID of the current shell". left && right means "if left returned no error, execute right.

In this case it might be better to separate the commands with ; which means all commands will be executed regardless of the success of the previous command. I've thrown a sleep in there too. I don't know if it's necessary, but it might help make it a little more robust - some interfaces like to be left alone for a few seconds before you brind them back up.
Code:

ifconfig eth0 down ; sleep 2 ; ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up

matthewg42 12-01-2006 06:24 AM

One more thing. Bringing down the putty session might stop the commands after "ifconfig eth0 down" from running. Consider running it all inside a screen session.

farslayer 12-01-2006 10:36 AM

if you edit the network config manually I would think you could also use

/etc/init.d/networking restart

amitsharma_26 12-01-2006 10:53 AM

ip addr add 172.16.16.19/22 dev eth0 broadcast 172.16.19.255

farslayer 12-01-2006 02:39 PM

Quote:

Originally Posted by amitsharma_26
ip addr add 172.16.16.19/22 dev eth0 broadcast 172.16.19.255


Is this response for this thread or was it supposed to be for something else ?

A little explanation along with the response would be helpful..

amitsharma_26 12-02-2006 09:45 AM

Quote:

Originally Posted by amitsharma_26
ip addr add 172.16.16.19/22 dev eth0 broadcast 172.16.19.255

That was pretty self explainable.

ip address add <ip>/<mask> dev <dev-name> broadcast <broadcast-ip(is required moreoften when you have not mentioned a mask)>


There are many other options availbale with ip add command, ip addr help would be more supportive for the rest.

farslayer 12-02-2006 11:14 AM

Code:

debian:~# ip addr add 172.16.16.19/22 dev eth0 broadcast 172.16.19.255
-su: ip: command not found

is that distro specific or part of a particular tool that needs to be installed ?
That's the reason I asked, because it doesn't seem to work..


A bit of searching finally turned up the answer..
in ordert to use ip addr add you must have the iproute package installed.

Quote:

debian:~# apt-cache search iproute
iproute - Professional tools to control the networking in Linux kernels
iproute-dev - Development package for iproute
iproute-doc - Professional tools to control the networking in Linux kernels
libabz0 - Miscellaneous useful routines

debian:~# apt-cache policy iproute
iproute:
Installed: (none)
Candidate: 20061002-2
Version table:
20061002-2 0
500 ftp://mirrors.kernel.org sid/main Packages

debian:~# apt-get install iproute
.
.
debian:~# ip addr help

Usage: ip addr {add|del} IFADDR dev STRING
ip addr {show|flush} [ dev STRING ] [ scope SCOPE-ID ]
[ to PREFIX ] [ FLAG-LIST ] [ label PATTERN ]
that's whay I was so confused by your response... It didn't work for me, because it requires another package to be installed that isn't installed by default, and the package name required was never mentioned.. I get it now..


All times are GMT -5. The time now is 04:07 AM.