Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

please tell, how to remotely up and down the port using ifconfig unix command?

$ ifconfig eth0 down
$ ifconfig eth0 up

where eth0 is my nic card interface!

share|improve this question

migrated from Mar 24 '12 at 4:31

This question came from our site for professional and enthusiast programmers.

Better be VERY careful with this. If you do it wrong, then you've turned off your network interface on the remote machine, and will have no way to get back in to bring it back up again. – Marc B Mar 24 '12 at 4:22
I agree, sounds very dicey. That said, "ifconfig eth0 down && ifconfig eth0 up" might work, but I haven't tried and I'm not sure what happens when your remote session disconnects when the interface goes down. Might need a "nohup" in there to prevent the process from terminating. Whatever you do, test thoroughly before trying it when it counts! – Jim G. Mar 24 '12 at 5:59
I think you're going to need to explain what is wrong with your current method, as you see it. There are some obvious problems here but let's hear it from you.. Also "etho" is probably a typo for "eth0". – grifferz Mar 24 '12 at 9:25
Why are you doing this? There may be a way to accomplish what you want without threatening your connection. – LawrenceC Nov 12 '13 at 16:52
I agree with previous posters that there might be a better approach if we know what exactly you're trying to achieve, but if I'd have to do this I'd put the ifconfig eth0 up command in a cron entry. – Teun Vink Nov 12 '13 at 17:05

You can do it on one line:

ifconfig eth0 down; ifconfig eth0 up

As noted above... just issuing the ifconfig down without the semicolon and the ifconfig up will cut you off from a remote machine.

You will need superuser access on most nix, if you use sudo make SURE you sudo both ifconfig statements.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .