ConfigurationDevice=eth0 #描述网卡对应的设备别名, for example, in Ifcfg-eth0 file it is eth0Bootproto=static #设置网卡获得ip地址的方式, the possible options are static,dhcp or BOOTP, corresponding to statically specified IP addresses, IP addresses obtained through the DHCP protocol, IP addresses obtained through the BOOTP protocolbroadcast=192.168.0.255 #对应的子网广播地址HWADDR=00:07:E9:05:E8:B4 #对应的网卡物理地址ipaddr=12.168.1.2 #如果设置网卡获得 IP
After installing a Linux system, we often need to do some initial configuration operations, the most visible is the need to modify the configuration of the following content.1, set the IP address, you can edit /etc/sysconfig/network-scripts/ifcfg-eth0Device=eth0//Physical Device NameBootproto=none//NONE|STATIC|BOOTP|DHCP (does not use protocol at boot time | static Assignment | BOOTP protocol | DHCP protoc
The code is as follows:
Vi/etc/resolv.conf
# Generated by NetworkManager
NameServer 192.168.159.2
2, modify the network configuration parameters of the file
/etc/sysconfig/network-scripts/ifcfg-eth0
File/etc/sysconfig/network-scripts/ifcfg-eth0 is located under this directory in/etc/sysconfig/network-script, which is a script file (control file) for network interface (NIC). Ifcfg-eth0 is the default first network interface, and if there are multiple network interfaces in the machine, the
, CentOS modify IP address
Modify the configuration file for the IP address of the corresponding network card
# Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Modify the following content
Device=eth0 #描述网卡对应的设备别名, for example, Ifcfg-eth0 in a file that is eth0Bootproto=static #设置网卡获得ip地址的方式, possible options for STATIC,DHCP or BOOTP, respectively corresponding to statically specified IP address, IP address obtained through DHCP protocol,
In the project as a result of the company's local area network automatically obtain IP way, to each server restart host IP will change. In order to solve this problem, I refer to other articles and set up static IP according to their own situation to solve the problem, the processing method is as follows:
1. Modify the network card configuration
Editor: Vi/etc/sysconfig/network-scripts/ifcfg-eth0
Device=eth0 #描述网卡对应的设备别名, for example, Ifcfg-eth0 in a file that is eth0
Bootproto=static #设
Ipaddr=addr addr represents the IP address assigned to the card
Netmask=maskmask represents a network mask
NETWORK=ADDRADDR represents the network address
Broadcast=addr addr Represents broadcast address
Onboot=yes/no whether the card is activated at startup
None: No need to start protocol
BOOTP: Using BOOTP protocol
DHCP: Using DHCP protocol
Userctl=yes/no whether to allow non-root users to contr
The following values are common in all basic configuration files:
* Device=name, where name is the name of the physical device (except for dynamically assigned PPP devices)
Its name is "logical name."
* Ipaddr=addr, here addr is the IP address.
* Netmask=mask, here Mask is a netmask.
* Network=addr, here addr is the network address.
* Broadcast=addr, here addr is the broadcast address.
* Gateway=addr, here addr is the gateway address.
* Onboot=answer, here answer take one of the followin
physical devices
Ipaddr=addr addr represents the IP address assigned to the card
Netmask=mask Mask represents a network mask
NETWORK=ADDR addr represents the network address
Broadcast=addr addr Represents broadcast address
Whether the card is activated when onboot=yes/no is activated
None: No activation protocol required
BOOTP: Using BOOTP protocol
DHCP: Using DHCP protocol
Userctl=yes/no whether
broadcast=208.164.186.255
Onboot=yes
Bootproto=none
Userctl=no
If you want to manually modify the network address or add a new network interface to the new interface, you can do so by modifying the corresponding file (IFCFG-ETHN) or by creating a new file.
Device=name name indicates the names of the physical devices
Ipaddr=addr addr represents the IP address assigned to the card
Netmask=mask Mask represents a network mask
NETWORK=ADDR addr represents the network address
Broadcast=addr
=192.168.1.0 #网络地址 (but not)broadcast=192.168.1.255 #广播地址 (but not)gateway=192.168.1.1 #网关地址Onboot=yes # [Yes|no] (whether the device is activated at boot time)Userctl=no #[yes|no] (whether a non-root user can control the device)Bootproto=static #[none|static|bootp|dhcp] (Do not use protocol at boot | static Allocation | BOOTP protocol | DHCP protocol)
Note: Single NIC binding two IPThe Linux devi
/SYSCONFIG/NETWORK-SCRIPTS/IFCFG-ETHN file
In Redhat, the configuration file for the system network device is saved under the "/etc/sysconfig/network-scripts" directory, Ifcfg-eth0 contains the configuration information for the first network card, and the configuration information that contains the second network card.
The following is an example of a "/etc/sysconfig/network-scripts/ifcfg-eth0" file:Device=eth0 device=name name indicates the names of the physical devicesipaddr=x.x.x.x ipaddr=add
connection, you can do so by modifying the corresponding file ifcfg-Device=Ipaddr=netmask=Broadcast=Onboot=yes/no whether the card is activated at startup
Bootproto=none None: No need to start protocol
BOOTP: Using BOOTP protocol
DHCP: Using DHCP protocol
Gateway=Macaddr=Userctl=yes/no whether to allow non-root users to control the device
2./etc/resolv.conf file
File/etc/resolv.conf configures the DNS cl
machine presenting the name ' Judge ' when # it asks for a DHCP lease. #dhcp-host=judge # Ignores DHCP requests for the following MAC address # Never an offer DHCP service to a machine whose Ethernet # adress is 11:22:33:44:55:66 #dhcp-host=11:22:33:44:55:66,ignore # DHCP is located in domain # Set the domain for DNSMASQ. This is optional, but if it is set, it # does the following things. # 1) allows DHCP hosts to have fully qualified domain names, as long # as the domain part matches this sett
the broadcast address.
* Gateway=addr, here addr is the gateway address.
* Onboot=answer, here answer take one of the following values:
o Yes-this device will be activated at boot time.
o No-this device is not activated when boot.
* Userctl=answer, here answer take one of the following values:
o Yes-a non-root user can control the device.
o No-the device is not allowed to be controlled by a non-root user.
* Bootproto=proto, here Proto take one of the following values:
o None--does not
File:/etc/sysconfig/network-scripts/ifcfg-eth0
The following values are common in all basic configuration files:
* Device=name, where name is the name of the physical device (except for dynamically assigned PPP devices)
Its name is "logical name."
* Ipaddr=addr, here addr is the IP address.
* Netmask=mask, here Mask is a netmask.
* Network=addr, here addr is the network address.
* Broadcast=addr, here addr is the broadcast address.
* Gateway=addr, here addr is the gateway address.
* Onb
host of things the DHCP address needs to be assigned and the native address must be on the same network segment otherwise it cannot start DHCP
The code is as follows:
Ddns-update-style Interim;
Allow booting;
Allow BOOTP;
Ignore client-updates;
Set vendorclass = option Vendor-class-identifier;
#修改为自己的网段
Subnet 192.168.0.0 netmask 255.255.255.0 {
#修改路由地址
Option routers 192.168.0.1;
#域名服务器地址
Option Domain-name-servers 202.106.0.20;
#子网
Op
with a static IP address, the file contains entries such as the following:Device="eth0"nm_controlled="Yes"Onboot=Yesuserctl=Notype=Ethernetbootproto=Nonedefroute=Yesipv4_failure_fatal=Yesipv6init=NoNAME="System eth0"UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03hwaddr= ,:xx: -: -: C3: -ipaddr=192.168.1.101NETMASK=255.255.255.0Broadcast=192.168.1.255Peerdns=yespeerroutes=yesThe following configuration parameters is typically used in interface configuration files:
BOOTPROTO
board Dhcp/bios through the BOOTP service to assign IP address for bootloader, configure network parameters, so as to support network transmission function. The u-boot that we use can set the network parameters directly, so there is no way to dynamically assign IP using DHCP. The bootloader of the target board then downloads the kernel image to the target board via the TFTP service, then establishes the file communication between the host and the tar
103 Linux Important Sub-directory description/etc/sysconfig/net-scripts/ifcfg-eth01) Restart the NIC/etc/init.d/network restart2) ifdown eth0 ifup eth0 only for Eth0 NIC, modified via setup network configurationdevice=eth0 Physical Device name eth1 represents the second nic hwaddr=xx: 0c::a6:a6:6d network card MAC address 48-bit type=Ethernet Ethernet uuid=a1d78f1f-e337-4366-8600-8b53579f9f95 the network card uniquely identifies the identity card as onboot=Yes is not on
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.