Jza Posted May 9, 2007 Report Share Posted May 9, 2007 Hi I want to change my IP from dynamic to static using the command line. Currently I will do something like this: Open Mandriva Control Center Go to Network and Internet Go to "Reconfigure Network Interface" On Device choose my ethernet card On Protocol switch from DHCP to Static Insert IP/Netmask/Gateway Click OK So I think on the cli the process will be something like: $ su Password **** $ ifconfig eth0 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255 up $ route add -net default gw 192.168.1.0 However what I want to know if how to find out what I am currently running on (DHCP or Static) before modifiying. Quote Link to comment Share on other sites More sharing options...
jaraeez Posted May 9, 2007 Report Share Posted May 9, 2007 I'm sure there many ways to 'skin a cat' the way I know is to do a cat /etc/sysconfig/network-scripts/ifcfg-eth0 file which will tell you (BOOTPROTO=static)... HTH Quote Link to comment Share on other sites More sharing options...
tyme Posted May 9, 2007 Report Share Posted May 9, 2007 I'm sure there many ways to 'skin a cat' the way I know is to do a cat /etc/sysconfig/network-scripts/ifcfg-eth0 file which will tell you (BOOTPROTO=static)That will only tell you what it was set up to do on boot. If you change settings via the command line, as Jza discusses in the first post, this file will not be modified and won't be particularly useful. If you change them in MCC it may get modified, but not if you're doing it from the CL. Jza: I'm not sure how to tell if you're using dhcp or static...I would do a man ifconfig and look through the options to see if there is anything useful in there. You could try running dhcpinfo, but I'm unsure what kind of result you'll get from it if you aren't connected via dhcp. Quote Link to comment Share on other sites More sharing options...
jboy Posted May 9, 2007 Report Share Posted May 9, 2007 (edited) However what I want to know if how to find out what I am currently running on (DHCP or Static) before modifiying. You should be able to get this from file: /etc/sysconfig/network-scripts/ifcfg-eth0 For instance, here is a sample content where static networking is configured (BOOTPROTO=static): DEVICE=eth0 BOOTPROTO=static IPADDR=192.168.1.115 NETMASK=255.255.255.0 NETWORK=192.168.1.0 BROADCAST=192.168.1.255 ONBOOT=yes METRIC=10 MII_NOT_SUPPORTED=no For more info: man ifcfg EDIT: Oops, jaraeez had already given this same answer, which I missed. Edited May 9, 2007 by jboy Quote Link to comment Share on other sites More sharing options...
jaraeez Posted May 9, 2007 Report Share Posted May 9, 2007 That will only tell you what it was set up to do on boot. If you change settings via the command line, as Jza discusses in the first post, this file will not be modified and won't be particularly useful. If you change them in MCC it may get modified, but not if you're doing it from the CL. well as i understood the OP was asking if there was a way to find out they had , but you obviously read minds as you assume! Quote Link to comment Share on other sites More sharing options...
tyme Posted May 9, 2007 Report Share Posted May 9, 2007 well as i understood the OP was asking if there was a way to find out they had , but you obviously read minds as you assume!Sorry...I hope my clarification didn't offend, it was not intended to. What I read was that Jza intends to switch between dhcp and static at various points and time, preferrably from the command line, and not necessarily rebooting between changes. If he switches to static as he suggests (from the CL), the config files won't change. If he leaves his system on, when he comes back to it, looking at that file won't give him the information he needs. That is, just because it was dhcp or static when he booted doesn't mean it still is - if at some point he changed it from the CL with ifconfig. I wasn't saying you were wrong or anything, I was simply trying to clarify what that file will tell him, and suggest a means which may give him the information he needs in all circumstances - whether he changed the config from the CL or changed it from MCC. and I assure you I don't read minds ;) Quote Link to comment Share on other sites More sharing options...
jaraeez Posted May 9, 2007 Report Share Posted May 9, 2007 Sorry...I hope my clarification didn't offend, it was not intended to. What I read was that Jza intends to switch between dhcp and static at various points and time, preferrably from the command line, and not necessarily rebooting between changes. If he switches to static as he suggests (from the CL), the config files won't change. If he leaves his system on, when he comes back to it, looking at that file won't give him the information he needs. That is, just because it was dhcp or static when he booted doesn't mean it still is - if at some point he changed it from the CL with ifconfig. I wasn't saying you were wrong or anything, I was simply trying to clarify what that file will tell him, and suggest a means which may give him the information he needs in all circumstances - whether he changed the config from the CL or changed it from MCC. and I assure you I don't read minds ;) you most certainly did not offend me on the contrary. Unforunately conversing via typing, notes, Emails etc in some cases loses the essence - & I'm glad you can't read minds, cos that's just TO dangerous ;) Quote Link to comment Share on other sites More sharing options...
iphitus Posted May 10, 2007 Report Share Posted May 10, 2007 only real way you can check is to check if the dhcp client is running/you still have a lease. This depends on what mandriva uses, afaik they use dhclient, which i know bugger all about. But if im wrong, and they use dhcpcd.... Leases are in /etc/dhcpc/ or /var/run/ depending on version and you could also just do "pgrep dhcpcd" to see if it's running, James Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.