1. Common Configuration Network Instructions
(1) Configure the IP address of the eth0 and activate the device
(2) Add default gateway
(3) Configure DNS
$ sudo vi/etc/resolv.conf
nameserver 202.96.134.133
nameserver 202.96.128.68
nameserver
View DNS
(4) Other orders
#激活设备
ifconfig eth0 up
#禁用设备
ifconfig eth0 down
2, determine the location of the network---tool ethtool
(1) Ethtool Devname View the device information corresponding to the device name Example:ethtool eth0
The last line shows link detected:yes/no
(2) Ethtool-p devname view the device location corresponding to the corresponding device name example:ethtool–p eth0
The light on the interface of the NIC corresponding to the eth0 after the carriage return will flash, so you can quickly determine the location of the Eth0 network. (Press CTRL + C to end the command, stop blinking)
3, Linux has two sets of management network connection scheme:
(1)/etc/network/interfaces (/etc/init.d/networking)
(2) Network-manager
The two sets of programmes are conflicting and cannot coexist at the same time.
The first scenario applies to environments where there is no x, such as servers, or where there is no need to change the connection at all.
The second scheme is used in the environment with desktop, especially the notebook, moved to move, the network connection situation can change at any time.
-------------
The two of them, in order to avoid conflict and share configuration, have the following solution:
1, when Network-manager found that the/etc/network/interfaces was changed, then close themselves (shown as unmanaged), unless the managed set to true.
2. When the managed is set to true, the/etc/network/interfaces is not effective.
If you want to configure the network at the command line, you may need to turn off the NetworkManager service, open the Network service, and execute with root permissions
Chkconfig--level 2345 networkmanager off chkconfig--level 2345 Network on
service NetworkManager Stop
Service Network start
4, configure the network, single network card single IP
(1) Redhat series
Edit/etc/sysconfig/network-scripts/ifcfg-eth[x] File ([x] for the network card used)
Static configuration
# xxxxxxx (Nic name, do not change)
device=eth0
bootproto=static
type=ether
hwaddr=xx:xx:xx:xx:xx:xx (Nic mac address, Do not change)
ipaddr=x.x.x.x (IP address)
netmask=x.x.x.x (subnet mask)
broadcast=x.x.x.x. (broadcast address)
network=x.x.x.x ( Network address)
gateway=x.x.x.x (gateway address)
Onboot=yes (power-on self-boot)
dns1=x.x.x.x (domain name server address)
dns2=x.x.x.x
Note: Onboot must be set to Yes, otherwise the following symptoms may occur, eth0 not eject:
Dynamic configuration
# xxxxxxx (Nic name, do not change)
device=eth0
bootproto=dhcp
type=ether
hwaddr=xx:xx:xx:xx:xx:xx (Nic mac address, do not change)
Onboot=yes (power-on self-starter)
(2) Ubuntu series
Edit file $ sudo vi/etc/network/interfaces
# The Loopback network interface (configuration loopback)
Auto lo # boot automatic lo interface
iface lo inet Loopback # Configure LO interface for loopback
# the Primary Network interface #配置主网络接口
auto eth0 #开机自动激活eth0接口
iface eth0 inet DHCP #配置eth0接口为DHCP自动获取
#或者配 Set eth0 to static address
# The Primary network interface (configure the primary network interface)
auto eth0 #开机自动激活eth0接口 iface eth0 inet
Static # Configure eth0 interface for static address
192.168.1.10
Gateway 192.168.1.254
Netmask 255.255.255.0
Network 192.168 .1.0
Broadcast 192.168.1.255
5, configure the network, single card multiple IP
Direct use of the command line, the system is universal, but is temporary
(1) Radhat series
Follow/etc/sysconfig/network-scripts/ifcfg-eth0 add a file name based on the name of the network virtual interface
such as ifcfg-eth0:0 or ifcfg-eth0:1, etc.
#下边看下ifcfg the configuration information inside the-eth0:0 file
device=eth0:0 #网络虚拟接口eth0:0
onboot=yes #启动的时候激活
bootproto=static #使用静态ip地址
ipaddr=192.168.0.1 #分配ip地址
netmask=255.255.255.0 #子网掩码
Other configuration files are similar.
Restart Network Services
(2) Ubuntu series
Add content directly to/etc/network/interfaces file
Auto eth0:0
iface eth0:0 inet static
name Ethernet Lan card address
192.168.0.2
netmask 255.255.255.0
Network 192.168.0.0
broadcast 192.168.0.255
#gateway 192.168.0.254
The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.