Table Of Contents 1 Table Of Contents ...............................................................................................................................

advertisement
Table Of Contents
1/5
Table Of Contents
Table Of Contents ............................................................................................................................... 1
Task: Define new DNS servers ........................................................................................................... 2
Task: Test DNS server ........................................................................................................................ 2
Network command line cheat sheet .................................................................................................... 3
Task: Display network interface information ....................................................................................... 3
Task: Take down network interface eth0 / take a network interface down .......................................... 3
Task: Bring a network interface eth0 up .............................................................................................. 3
Task: Change IP address and netmask from command line ............................................................... 3
Task: Display the routing table ............................................................................................................ 3
Task: Add a new gateway ................................................................................................................... 3
Task: Display current active Internet connections (servers and established connection) ................... 3
Task: Display open ports .................................................................................................................... 3
Task: Display network interfaces stats (RX/TX etc) ............................................................................ 4
Task: Display output for active/established connections only ............................................................. 4
Task: Test network connectivity .......................................................................................................... 4
Task: Use GUI (Graphical Configuration) network Tool ...................................................................... 4
Final tip - Learn how find out more information about commands ....................................................... 4
Task: Define new DNS servers
nixCraft: Linux Tips, Hacks, Tutorials, And Ideas In Blog Format
http://www.cyberciti.biz/
Home > Ubuntu Linux
Howto: Ubuntu Linux convert DHCP network configuration to static IP configuration
Posted by Vivek Gite <vivek@nixcraft.com> [52 Comments]
My friend wanted to know how to change or convert DHCP network configuration to static configuration. After initial
installation, he wanted to change network settings. Further, his system is w/o GUI system aka X Windows. Here is quick
way to accomplish the same:
Your main network configuration file is /etc/network/interfaces
Desired new sample settings:
=> Host IP address 192.168.1.100
=> Netmask: 255.255.255.0
=> Network ID: 192.168.1.0
=> Broadcast IP: 192.168.1.255
=> Gateway/Router IP: 192.168.1.254
=> DNS Server: 192.168.1.254
Open network configuration file
$ sudo vi /etc/network/interfaces
OR
$ sudo nano /etc/network/interfaces
Find and remove dhcp entry:
iface eth0 inet dhcp
Append new network settings:
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
Save and close the file. Restart the network:
$ sudo /etc/init.d/networking restart
Task: Define new DNS servers
Open /etc/resolv.conf file
$ sudo vi /etc/resolv.conf
You need to remove old DNS server assigned by DHCP server:
search myisp.com
nameserver 192.168.1.254
nameserver 202.54.1.20
nameserver 202.54.1.30
Save and close the file.
Task: Test DNS server
$ host cyberciti.biz
2/5
Network command line cheat sheet
3/5
Network command line cheat sheet
You can also use commands to change settings. Please note that these settings are temporary and not the permanent.
Use above method to make network changes permanent or GUI tool as described below.
Task: Display network interface information
$ ifconfig
Task: Take down network interface eth0 / take a network interface down
$ sudo ifconfig eth0 down
OR
$ sudo ifdown eth0
Task: Bring a network interface eth0 up
$ sudo ifconfig eth0 up
OR
$ sudo ifup eth0
Task: Change IP address and netmask from command line
Activate network interface eth0 with a new IP (192.168.1.50) / netmask:
$ sudo ifconfig eth0 192.168.1.50 netmask 255.255.255.0 up
Task: Display the routing table
$ /sbin/route
OR
$ /sbin/route -n
Output:
Kernel IP routing table
Destination
Gateway
localnet
*
172.16.114.0
*
172.16.236.0
*
default
192.168.1.254
Genmask
255.255.255.0
255.255.255.0
255.255.255.0
0.0.0.0
Flags
U
U
U
UG
Metric
0
0
0
0
Ref
0
0
0
0
Use
0
0
0
0
Iface
ra0
eth0
eth1
ra0
Task: Add a new gateway
$ sudo route add default gw 172.16.236.0
Task: Display current active Internet connections (servers and established connection)
$ netstat -nat
Task: Display open ports
$ sudo netstat -tulp
OR
Task: Display network interfaces stats (RX/TX etc)
$ sudo netstat -tulpn
Task: Display network interfaces stats (RX/TX etc)
$ netstat -i
Task: Display output for active/established connections only
$ netstat -e
$ netstat -te
$ netstat -tue
Where,
-t : TCP connections
-u : UDP connections
-e : Established
Task: Test network connectivity
Send ICMP ECHO_REQUEST to network hosts, routers, servers etc with ping command. This verifies connectivity
exists between local host and remote network system:
$ ping router
$ ping 192.168.1.254
$ ping cyberciti.biz
See simple Linux system monitoring with ping command and scripts [1] for more information.
Task: Use GUI (Graphical Configuration) network Tool
If you are new, use GUI configuration tool, type the following command at terminal:
$ network-admin &
Above command is Ubuntu's GUI for configuring network connections tool.
Final tip - Learn how find out more information about commands
A man page is your best friend when you wanted to learn more about particular command or syntax. For example, read
detailed information about ifconfig and netstat command:
$ man ifconfig
$ man netstat
Just get a short help with all command options by appending --help option to each command:
$ netstat --help
Find out what command is used for particular task by searching the short descriptions and manual page names for the
keyword:
$ man -k 'delete directory'
$ apropos -s 1 remove
Display short descriptions of a command:
$ whatis rm
$ whatis netstat
Linux offers an excellent collection of utilities, which can be use to finding the files and executables, remember you
cannot memorize [2] all the commands and files ;)
4/5
Task: Display network interfaces stats (RX/TX etc)
4000+ howtos and counting! Want to read more Linux / UNIX howtos, tips and
tricks? Subscribe to our free daily email newsletter or weekly newsletter to make
sure you don't miss a single tip/tricks. Alternatively, subscribe via RSS/XML feed.
Article printed from nixCraft: http://www.cyberciti.biz/
URL to article: http://www.cyberciti.biz/tips/howto-ubuntu-linux-convert-dhcp-network-configuration-to-static-ipconfiguration.html
URLs in this post:
[1] simple Linux system monitoring with ping command and scripts: http://www.cyberciti.biz/tips/simple-linux-and-unixsystem-monitoring-with-ping-command-and-scripts.html
[2] cannot memorize: http://www.cyberciti.biz/nixcraft/vivek/blogger/2005/10/linux-commands-to-help-younavigate.html
Copyright © 2004-2010 nixCraft. All rights reserved. This print / pdf version is for personal non-commercial use only. More
details - http://www.cyberciti.biz/tips/copyright
5/5
Download