Using the ifconfig Command
- 0
- Add a Comment
- No Related Post
Joe Barr has checked in with a new CLI Magic column, this time covering the ifconfig command. ifconfig is a very handy command for managing all of the network interfaces on your system.
I use the ifconfig frequently when bringing my laptop to work. We don’t have a DHCP server running (which I intend to rectify — with a Linux solution, of course — by next week), so I have to configure my Ethernet connection every time I hook up. Entering two simple lines on the command line is much faster than tracking down a GUI tool and clicking across all the boxes.
Why two lines? I also need the route command, which Barr doesn’t cover in this article. Specifically, here are the commands I enter (IP addresses concealed to protect the innocent):
ifconfig eth0 xxx.xxx.xxx.40 netmask 255.255.255.224
route add -net 0.0.0.0 gw xxx.xxx.xxx.33
I only have to add the netmask switch because I’m on a subnet of our network. The route command creates a default non-local route (essentially, anything beyond my immediate network) through our gateway (a VLAN on our router).
I plan to create a script to handle it all before long. I intend to create a handful of wired profiles (different connections at work, a wired interface for home and a local fire department I do tech work for, etc.) which will be controlled by the script based on feedback. For example, maybe it will ask “Where are you?” and “Which interface are you configuring?” and configure my connection appropriately.
If I ever get around to it, I’ll be sure to share.
