Linux Network management--linux network configuration

Source: Internet
Author: User
Tags uuid

<title>2. Linux Network Configuration</title> 2. Linux Network Configuration 2.0 IP address configuration

How to configure IP addresses for Linux

    1. Ifconfig command temporarily configures IP address
    2. Setup tool permanently configures IP address
    3. To modify a network configuration file
    4. Graphical interface configuration IP address (slightly)
2.1 ifconfig Command
    • ifconfigCommand: View and configure network status commands (there is a similar command in Windows ipconfig )
1.lo:flags= the<UP,LOOPBACK,RUNNING> MTU65536
2.inet127.0. 0. 1Netmask255.0. 0. 0
3.INET6::1Prefixlen -ScopeID0x104.Loop Txqueuelen0(Local Loopback)
5.RX Packets2194bytes162964(159.1KiB)
6.RX errors0Dropped0Overruns0Frame0
7.TX Packets2194bytes162964(159.1KiB)
8.TX errors0Dropped0Overruns0Carrier0Collisions0
9.

Note: One of the network card is called Lo, it does not make much sense to our actual work, the network card even if the cable can be ping-tong. It just means that our current network is normal.

    • Temporary configuration
1.192.168.0.200255.255.255.0
2.#临时设置eth0网卡的IP地址与子网掩码

General Linux's first Ethernet card is eth0, some versions of this network card is called ENP3S0, but the name is different, the actual content is the same. We can also manually change the NIC back to Eth0.

2.2 Setup Tool

Redhat Proprietary graphical tools setup set IP address
When you're done, run service network restart
Note: If IP is used in DHCP mode, the IP address column is written*

2.3 Configuring IP addresses with files (standard)

① Network card information file
(In fact, Setup will eventually write the information to this file as well)

1.[[Email protected] ~]# vi/etc/sysconfig/network-scripts/ifcfg-eth0 #注意自己的网卡名, ifconfig check it out.
2.Device=eth0#网卡设备名 (Remember we mentioned earlier that Enp3s0 Nic can be changed back to eth0? That's it)
3.Bootproto=none#是否自动获取IP (None, Static), DHCP (dynamic))
4.Hwaddr=xx:0C: in: -: C4: the #MAC地址
5.Nm_controlled=yes#是否可以由Network Manager Graphical management tool hosting
6.Onboot=yes#是否随网络服务启动, eth0 effective
7.Type=ethernet#类型是以太网
8.Uuid="44b76c8a-b59f-44d5-83fa-7f98fda86b3d" #唯一识别码
9.Ipaddr=192.168. 0. 252 #IP地址
.netmask=255.255. 255. 0 #子网掩码
One by one .gateway=192.168. 0. 1 #网关
.dns1=202.106. 0. #DNS
.Ipv6init=no#是否启用IPv6
.Userctl=no#是否允许非USER用户控制

Attention:

    • Linux files are strictly case-sensitive
    • To obtain an IP address automatically, you must have a DHCP server in the LAN. If DHCP is automatically obtained, then only the DEVICE, Bootproto, HWADDR, Onboot, and TYPE can be filled in.
    • Nm_controlled=yes The premise is that the network Manager must be installed, if not installed or maintenance when the service is banned, then the network card when the boot may be error. Otherwise, fill in No.
    • Onboot this in the use of ifconfig or Setup to change the information by default will be changed to No, so the network service startup is not find the network card, you have to manually open the network card.
    • UUID errors generally appear in the clone of the virtual machine, if the UUID of the two machines is also not able to be recognized in the computer, so no internet access

② Host name File

1.[root@localhost ~]# vi /etc/sysconfig/network
2.NETWORKING=yes #网络工作是否工作
3.#主机名
4.
5.[root@localhost ~]# hostname [主机名]
6.#查看与临时设置主机名命令

③dns configuration file

1.[[email protected] ~]# vi /etc/resolv.conf
2.202.106.0.20#名称服务器
3.search localhost #如果在浏览器中没有写全域名,这个就是默认域名
2.4 Virtual Machine Network parameter configuration

① Configuring LINUXIP Addresses

1.[root@localhost ~]# setup
2.#修改并配置IP地址

② starting the NIC

1.[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
2.把 ONBOOT=no
3.改成 ONBOOT=yes
4.
5.[root@localhost ~]# service network restart
6.#重启网络服务

③ Modify UUID (if virtual machine is cloned), resolve UUID conflict domain problem

1.  [Root@ localhost  ~]# vi/etc/sysconfig/network-scripts/ifcfg-eth0  
2. #删除MAC地址行
3.
4. [Root @localhost ~] # rm-rf/etc/udev/rules.d/70-persistent-net.rules
5. #删除网卡和MAC地址绑定文件
6.
7. [Root @localhost ~] # shutdown
8. #重启系统

④ Setting the virtual machine network connection mode
Bridging: Use the real network card, the real IP, you can communicate with other LAN hosts. In the campus network is not a good use, but if there is a router, it is recommended this way.
NAT: Constructs a virtual network card, can communicate with the network through the host, but cannot communicate with the LAN.
Host-only: Can communicate with LAN host, but cannot communicate with external network.
⑤ Modifying the bridge adapter
Set which network card to bridge, if you use a wired network card, then the virtual machine will be bridged to the wired network card. If you are using a wireless network card, the virtual machine will be bridged to the wireless card.

Linux Network management--linux network configuration

Related Article

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.