Linux Network Properties Configuration-Modify configuration file

Source: Internet
Author: User

Modifying a configuration file

1, IP, MASK, GW, the location of the DNS configuration file:

/etc/sysconfig/network-scripts/ifcfg-iface

[Email protected] ~]# vim/etc/sysconfig/network-scripts/ifcfg-Ens33type=Ethernet interface type, common with Ethernet (Ethernet), Bridge (bridging interface) Bootproto=DHCP activates what protocol this interface uses to configure interface properties: Dhcp,boot,static,nonedefroute=Yes Peerdns=Yes if the value of Bootproto is "DHCP", whether DHCP is allowed
DNS1: The first DNS server points to; If the configuration file for/etc/resolve is also available, it is preferred here
DNS2: Alternate DNS server points to; Peerroutes=Yesipv4_failure_fatal=Noipv6init=Yes whether to initialize ipv6ipv6_autoconf=Yesipv6_defroute=Yesipv6_peerdns=yesipv6_peerroutes=Yesipv6_failure_fatal=Noipv6_addr_gen_mode=stable-Privacyname=Ens33uuid=0ea5507b-feab-4d8a-b582-e1874ca0bb97 Unique identification device for this appliance=ENS33 The device name that corresponds to this configuration file OnbootWhether this interface is activated during the system boot process when the =yes operating system starts
IPADDR: Specify the IP address;
NETMASK: Subnet mask; CentOS 7 supports using prefix to specify the subnet mask in length;
Gateway: Default gateways;
Userctl: Whether to allow ordinary users to control the device;

eg

 # vim Ifcfg-eth0  1 , setting: bootproto=<        Span style= "COLOR: #0000ff" >static  2  , add: ipaddr  =172.16 . 100.12   NETMASK  =255.255 . 0.0   GATEWAY  =172.16 . 0.1   DNS1  =172.16 . 0.1   # route -n execute command, View found at this time does not take effect, restart after the AfterEffect # ifconfig eth0 down ifconfig eth0 up disable the network card, and then restart, not recommended, it is recommended to restart the Network # Service network restart restart  

Description: # service network restart equivalent #/etc/rc.d/init/d/network restart

The service command invokes the above script and passes the parameters restart

2. Configure Routing

Configuration file Location:/etc/sysyconfig/network-scripts/route-iface

Supports two configurations, when not mixed

(1), one route entry per line:

TARGET VIA GW

(2) One route entry per three lines:

Address#=target (#:0.1.2.3 .... )
Netmask#=mask: The mask corresponding to the destination address
Gateway#=nexthop: Indicates the gateway

eg

# Configure the routing file for eno33554984:

[Email protected] network-scripts]# vim route-eno33554984[[email protected] network-scripts]# cat route-   10.0. 0.0/8192.168. 0.1 or, in the following format: ADDRESS0=20.0. 0.0 NETMASK0=255.0. 0.0 GATEWAY0=192.168. 10.2

Configure multiple addresses for the NIC interface

In addition to IP addr, ifconfig or configuration files are available;

1, Ifconfig

Format:

# ifconfig Iface_label Ipaddr/netmask

Description: Iface_label: Similar to Eth0:0,eth0:1

eg

[Email protected] ~]#ifconfig ens33:0 172.22.132.26[[Email protected]~]# ifconfigens33:flags=4163<UP,BROADCAST,RUNNING,MULTICAST> MTU theinet192.168.22.133Netmask255.255.255.0Broadcast192.168.22.255Inet6 fe80::e508:e81e:801f:4073Prefixlen -ScopeID0x20<link>etherxx: 0c: in:d 3: the: theTxqueuelen +(Ethernet) RX packets5235bytes481513(470.2KiB) RX Errors0Dropped0Overruns0Frame0TX Packets4234bytes488692(477.2KiB) TX Errors0Dropped0Overruns0Carrier0Collisions0ens33:0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> MTU theinet172.22.132.26Netmask255.255.0.0Broadcast172.22.255.255etherxx: 0c: in:d 3: the: theTxqueuelen +(Ethernet)

2. IP

Format: # ip addr Add ip dev DEVICE label Iface_label

3. Add a configuration file to the NIC alias

There are only two places that need to be modified on the basis of the settings profile mentioned above:

Device= "ens33:0"

Ipaddr= .....

Note the NIC alias does not support the dynamic acquisition of addresses, so it can be used: Static,none

The TUI tool for Linux Network properties configuration

    • Tui:text user interface, text Interface tool
    • Command tool: # System-config-network-tui

Note: The configuration file will be modified directly after saving and will not be immediately available, restart the Network service, or use Setup to locate

Configure the host for the current host people

1. Command: hostname

2. Modify the configuration file

/etc/sysconfig/nerwork

eg

[Email protected] ~]# cat/etc/sysconfig/network# Created by anacondahostname=~]# Hostnamelocalhost.localdomain  

NMCLI command

1, CentOS7 on the IP configuration of carrying a command

2. Format:

NMCLI [OPTIONS] OBJECT {COMMAND | help}

OBJECT:

1. Device: View and manage network interfaces

COMMAND = {Status | show | connect | disconnect | delete | wifi | wimax}

2, Connection: Open, prohibit management network connection

COMMAND = {show| up | | | add | edit | modify | delete | reload | load}

Note: Connection can be abbreviated to Conn

eg

# Display Device

[[Email protected] ~]# nmcli device showgeneral. Devices: Virbr0general. Type: bridgegeneral. HDD :                            the: Wu:xx: -: *: -General . MTU: theGeneral . Status: -(connected) general. CONNECTION:virbr0GENERAL.CON-path:/org/freedesktop/networkmanager/activeconnection/1IP4. Address [1]:192.168.122.1/ -IP4. Gateway: IP6. Gateway:

# Show Device status

[[Email protected] ~]# nmcli Device status equipment        type      status    CONNECTION virbr0      bridge    connection  virbr0     ENS33       Ethernet  connected  ens33      lo          loopback  not managed   --         virbr0- Nic  Tun       not managed  --      

3, how to modify the IP address and other properties

Format: # NMCLI conn Modify IFACE [+|-]setting.property value

Description: Modify supports modifying the following parameters:

Ipv4.address

Ipv4.gateway

Ipv4.dns1

Ipv4.method

Manual

Note: This command is not yet mature, add the address, the first down to take effect

eg

[Email protected] network-scripts]# NMCLI conn Modify eno33554984 +ipv4.address192.168.200.10/ -[[Email protected] network-scripts]# nmcli conn down Eno33554984[[email protected] network-scripts]# nmcli conn up eno33554984[[email protected] network-scripts]# nmcli Conn show[[email protected] Network-scripts]# NMCLI Conn Modify Eno33554984-ipv4.address192.168.200.10/ -[[Email protected] network-scripts]# nmcli conn down Eno33554984[[email protected] network-scripts]# nmcli conn up eno33554984[[email protected] network-scripts]# NMCLI Conn Show

 

Add:

Network services:

Network and NetworkManager

The best use of network in CENTOS6

Centos7 with NetworkManager

Manage network Services :

CentOS 6:service Service {start|stop|restart|status (view status)}

CentOS 7:systemctl {start|stop|restart|status} Service[.service]

After the configuration file modification, need to restart the network service for the configuration file to take effect oh;

CentOS 6:# Service Network restart

CentOS 7:# systemctl Restart Network.service

Centos7 can also be used in the same way as 6, just not very formal.

  

  

Linux Network Properties Configuration-Modify configuration file

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.