The recent work often have to reload the system, so you have to configure the network. This should be said to be very simple in Windows, a few seconds to finish.
But under Linux, sometimes a bit of trouble, there is a good window interface, the general will provide the appropriate window for network configuration. As in Ubuntu, there are system->administration->network in which Ip,host,dns can be configured.
But I am the remote machine configuration, with the server on the blade of the IMM or AMM to connect, interface operation is sometimes really too card.
Therefore, the command line is a good choice. Come down and I'll introduce some common methods.
1. By modifying the network configuration file
/etc/network/interfaces
Network interface parameter configuration file, the following is a configuration example, there are two network interfaces, where eth0 assigns static IP address, eth1 dynamically obtain IP address:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, interfaces (5).
# The Loopback network interface
Auto Lo
Iface Lo inet Loopback
# The Primary network interface
Auto Eth0
Iface eth0 inet Static
Address 192.168.1.254
Network 192.168.1.0
Netmask 255.255.255.0
Broadcast 192.168.1.255
Gateway 192.168.1.1
Auto Eth1
Iface eth1 inet DHCP
The network device needs to be restarted after the modification is complete
#/etc/init.d/networking Restart
Configuring DNS modifies the/etc/resolve.conf file.
Search necas.nec.com.cn
NameServer 192.168.203.2
The configuration hostname is modified/etc/hosts
127.0.0.1 localhost
127.0.0.1 Cobain
After configuring hostname, you can use ping to test whether your hostname is already through.
Ping Yourhostname
This completes a network configuration needs to configure the IP information, DSN information, hostname information configuration.
But for different Linux, the configuration files may be different, and the above is tested in Ubuntu.
There are some differences in red hat.
The host name and default gateway are saved in the/etc/sysconfig/network file.
The network configuration information is stored in the NIC device file/etc/sysconfig/network-scripts/ifcfg-ethn where n is the number of the NIC.
Device=eth0
Bootproto=static
broadcast=192.168.203.255
Ipaddr= 192.168.203.2
netmask=255.255.255.0
network= 192.168.203.9
gateway= 192.168.203.1
Hostname=cobain
Onboot=yes
Type=ethernet
It looks like you can also modify the hostname and default gateways.
In short, the above can be completed once network configuration.
2. Use command line configuration
As long as the ifconfig command is applied.
The network interface used to configure the resident kernel. It is used to set the network interface when booting successfully. Thereafter, it is only used when debugging and system tuning is required.
Command format:
Ifconfig [Interface]
Ifconfig interface [Aftype] options | Address ...
If no arguments are given, ifconfig displays the status of the current active interface. Given a single interface as a parameter, it shows only the state of the given interface, and if given a-a parameter, it displays the state of all interfaces, including those that are deactivated. Otherwise, an interface is configured.
Options
Interface interface name. Typically a driver name followed by a unit number, such as the first Ethernet interface eth0.
Up
This option activates the interface. If an address is declared to an interface, this option is implicitly declared.
Down
This option closes the interface-driven device.
Netmask Addr
Sets the IP netmask for the interface. The default value is typically a, B, or C network mask (launched by an interface's IP address), but it can also be set to a different value.
Add Addr/prefixlen
Adds an IPV6 address to the interface.
Del Addr/prefixlen
Deletes an IPV6 address for the interface.
HW Class Address
such as interface driver support, set the hardware address of the interface. This option must be followed by the type name of the hardware and the equivalent printable ASCII character of the hardware address. The types of hardware currently supported include Ether (Ethernet), ax25 (Ampr ax.25), ARCnet and Netrom (AMPR net/rom)
To view network information using the Ifconfig command:
Ifconfig
Eth0 Link encap:ethernet hwaddr 00:15:58:3e:f2:6b
inet addr:192.168.1.254 bcast:192.168.1.255 mask:255.255.255.0
Inet6 ADDR:FE80::215:58FF:FE3E:F26B/64 Scope:link
Up broadcast RUNNING multicast mtu:1500 metric:1
RX packets:29458 errors:0 dropped:0 overruns:0 frame:0
TX packets:23690 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10945195 (10.4 MiB) TX bytes:2935004 (2.7 MiB)
interrupt:169 Base address:0xe200
eth0:0 Link encap:ethernet hwaddr 00:15:58:3e:f2:6b
inet addr:192.168.1.244 bcast:192.168.1.255 mask:255.255.255.0
Up broadcast RUNNING multicast mtu:1500 metric:1
interrupt:169 Base address:0xe200
Lo Link encap:local Loopback
inet addr:127.0.0.1 mask:255.0.0.0
Inet6 addr::: 1/128 scope:host
Up loopback RUNNING mtu:16436 metric:1
RX packets:354 errors:0 dropped:0 overruns:0 frame:0
TX packets:354 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:45062 (44.0 KiB) TX bytes:45062 (44.0 KiB)
Ppp0 Link Encap:point-to-point Protocol
inet addr:18.18.18.13 p-t-p:18.18.18.1 mask:255.255.255.255
Up Pointopoint RUNNING noarp multicast mtu:1396 metric:1
RX packets:9631 errors:0 dropped:0 overruns:0 frame:0
TX packets:9189 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 Txqueuelen:3
RX bytes:8460352 (8.0 MiB) TX bytes:913898 (892.4 KiB)
The first format of the ifconfig (or the ifconfig command with no arguments) can be used to view the network configuration of the current system.
* Eth0: Indicates the network card code
* Lo:linux Internal network loopback address, used to simulate network behavior,
* HWADDR: The hardware address of the network card, namely MAC address
* inet Addr: IP address of the network card
* Bcast: Broadcast address (broadcast);
* Mask: Subnet mask;
* MTU: The abbreviation for the Maximum Transmission Unit (Maximum trasmission), which indicates the maximum number of packets that can be transmitted for this network interface, which may cause network failure.
* RX: The network from the start to the current data received
* TX: Transmission of data from start to date
* Collisions: The situation of network signal conflict;
Activating network devices
Ifconfig eth0 up
Change Network device information
#ifconfig eth0 192.168.1.112 netmask 255.255.255.0
Turn off network devices