Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Network Management under CentOS6

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Blog catalogue

Brief introduction

We all know that in our Internet, all communications are completed through the network, of course, there must be a corresponding address, the MAC address is fixed, so only the IP address can be changed, so today we will show you how to configure the network card in CentOS6. Of course, all the commands below are done in CentOS6.

I. the configuration file of the network card

1. Commands for operating the network card

Ifconfig

Ifconfig directly enters the network card to view the activity

Ifconfig-a check all the network card information active and inactive

Ifconfig Nic name specifies Nic query

The name of the ifconfig down network card closes the designated network card and shuts down the device directly

The specified network card is enabled by the name of the ifconfig up network card, which is directly opened here.

Ifdown cancels device IP

Ifup Activation device IP

Add temporary IP to ifconfig eth0 IP/ subnet

Ip

Ip a view all the information of the network card

Link operates on the data link layer

Addr operates on the network layer

Add IP

Usage

Ip addr add 3.3.3.3/24 dev eth2

Label tagging

Usage

Ip addr add 3.3.3.4/24 dev eth2 label eth2:3

Flush clears all IP addresses

Usage

Ip addr flush eth2

Route operates on routing tables

Ip route add destination address via Gateway

Del deletion

Flush emptying

1.1.The configuration file of the network card in CentOS6 is stored in / etc/sysconfig/network-scripts/

[root@centos6 boot] # ls / etc/sysconfig/network-scripts/ifcfg-eth0 ifcfg-lo

Network card profile

Touch / etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth2 device name

ONBOOT=yes booting automatically

BOOTPROTO=static sets ip to get protocol dhcp | static

IPADDR=6.6.6.6 sets IP

PREFIX=8 sets subnet mask

GATEWAY=6.6.6.1 Settings Gateway

DNS1=114.114.114.114 sets the master DNS

DNS2=8.8.8.8 sets backup DNS

DNS3=8.8.4.4 sets backup DNS (up to 3 DNS)

DOMAIN=magedu.com sets the domain name (when the input domain name is incomplete, the system automatically completes this domain name)

HWADDR=00:00:00:00:00:00 device MAC address

MACADDR=00:00:00:00:00:00 modifies the device MAC address

| PEERDNS=yes | whether the no setting automatically acquires DNS |

Determine a hardware Nic DEVICE | HWADDR | MACADDR

Gateways can also be configured in Centos6 / etc/network

Add GATEWAY=0.0.0.0 Gateway addr

If the network file conflicts with the network card profile, the gateway takes priority in taking effect of the network card profile.

[root@centos6 ~] # cat / etc/sysconfig/network-scripts/ifcfg-eth0DEVICE=eth0TYPE=EthernetUUID=99326609-c6e3-4a5bMurb2bMuhashi c8906da2e50fONBOOTLEDroomyesBOOTPROTOBER noneDEFROTENTOTED IPV4FAILUREFATALYYesIPV6INITnoNAME = "System eth0" HWADDR=00:0C:29:9E:B6:C9IPADDR=172.18.17.10PREFIX=16GATEWAY=172.18.0.1LAST_CONNECT=1489456625

Add an alias to the network card

Add a network card alias

Ifconfig network card alias IP

Ifconfig eth2:1 172.168.1.1/16

Ip addr add IP dev network card label network card alias

Ip addr add 172.16.1.1/16 dev eth0 label eth0:0

Delete network card alias

Ip addr del 172.16.1.1/16 dev eth0 label eth0:0

Clear the network card alias

Ipaddrflush dev eth0 label eth0:0

Add a network card alias to Centos6

Permanently add a network card alias (NetworkManager must be closed)

Cp / etc/sysconfig/network-scripts/ifcfg-eth0 {,: 100}

Modify content

DIVICE

IPADDR

DNS profile

/ etc/resolv.conf this file is automatically generated

Hosts has higher priority than DNS

Modify the priority file vim / etc/nsswitch.conf

Just change the location of hosts filesdns.

The method of changing CentOS6 Network Card

Enable biosdevname software based on BIOS support

Internal network card: em1,em2

PCI card: pYpXY:slot, X:port

(2) the format of name composition

En: Ethernet wired LAN

Wl: wlan Wireless Local area Network

Ww: wwan Wireless wide area Network

Name type:

O: the device index number of the integrated device

S: the index number of the expansion slot

X: naming based on MAC address

Ps: enp2s1

Summary of network cards and aliases

Generate a separate interface profile for each device alias

Turn off the NetworkManager service

Ifcfg-ethX:xxx

Static networking must be used

DEVICE=eth0:0

IPADDR=10.10.10.10

NETMASK=255.0.0.0

ONPARENT=yes

Note: service network restart takes effect

NetworkManager: a graphical management tool

NetworkManager in Centos6 is not mature.

Therefore, it is recommended to shut down the service.

Service NetworkManager stop chkconfig NetworkManager off

Reference / usr/share/doc/initscripts-*/sysconfig.txt

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report