Find the answer to your Linux question:
Results 1 to 5 of 5
Hi, I am trying to work out how to disable a NIC in Linux programmatically. I have a couple of questions. 1) Will disabling a NIC programmatically still require as ...
  1. #1
    Just Joined!
    Join Date
    Dec 2007
    Posts
    6

    How to disable a NIC programmatically

    Hi,

    I am trying to work out how to disable a NIC in Linux programmatically. I have a couple of questions.

    1) Will disabling a NIC programmatically still require as user high privileges as just calling ifconfig -down?
    2) So far the only way I can see to disable the NIC is using ioctl or maybe the dev_close method. I am struggling to find helpful information on this to show me how to use it. Is this the correct direction to go and does anyway suggest any useful books/websites on this?

    Mmmm, I think that was more than two questions.

    Please help, I am beginning to go bald with all the hair pulling.

    Marc

  2. #2
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Quote Originally Posted by marct View Post
    Hi,
    1) Will disabling a NIC programmatically still require as user high privileges as just calling ifconfig -down?
    depends, you can do it the "Dark" way.
    which is giving the user a root running daemon that you can use.
    OR
    you can change the r/w rights on the Device you want to shutdown.
    OR
    you can do it the Idiot way. And that is DDOSing your own eth card till it stops working..

    Id do the second if Id were you.

    Cheers,
    Robin
    New Users, please read this..
    Google first, then ask..

  3. #3
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    1) Will disabling a NIC programmatically still require as user high privileges as just calling ifconfig -down?
    Yes.
    2) So far the only way I can see to disable the NIC is using ioctl or maybe the dev_close method. I am struggling to find helpful information on this to show me how to use it. Is this the correct direction to go
    Yes. You want ioctl(), using the SIOCGIFFLAGS and SIOCSIFFLAGS requests.
    and does anyway suggest any useful books/websites on this?
    Yes. If you're serious about network programming, you'll thank yourself later if you buy the Addison-Wesley book UNIX Network Programming by W. Richard Stevens (of happy memory), Bill Fenner, and Andrew M. Rudoff and curl up on a rainy weekend and explore that book in depth.
    Mmmm, I think that was more than two questions.
    Yes.
    Please help, I am beginning to go bald with all the hair pulling.
    Yes. Refer to chapter 32 of that book. (I had to pull it off the shelf to see how many chapters it has. 31.)
    --
    Bill

    Old age and treachery will overcome youth and skill.

  4. #4
    Just Joined!
    Join Date
    Dec 2007
    Posts
    6
    Firstly, thanks for the very quick responses.

    Robin, you mentioned you can change the r/w rights on the Device you want to shutdown. How exactly do you do this? Is it something that can be done at install time?

    Thanks
    Marc

  5. #5
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Yea.
    Code:
    chmod 777 /dev/eth0
    (thats really rough )

    But well that should do it..

    At the Wireshark Help file that is a tutorial that shows how you can make a user maintain the ethernet cards. (Lisern Mode)
    Well, I hope that helps.
    New Users, please read this..
    Google first, then ask..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...