Network Settings of Enterprise Servers--Network Settings under linux

Posted by kucing on Sun, 12 May 2019 06:13:21 +0200

Network configuration under linux

1. What is IP ADDRESS

internet protocol ADDRESS	##Network process address

ipv4	internet protocol version 4

ip It consists of 32 0,1.
11111110.11111110.11111110.11111110=254.254.254.254

2. Subnet mask

Used to divide the network area
The digital bits on the ip corresponding to the non-zero bits of the subnet mask represent the network bits of the ip
The number on 0 bits of subnet mask corresponds to the host of ip
Network bits represent network areas
Host bit represents a host in a network area

3.ip communication decision

Two IPS with identical network bits and inconsistent host bits can communicate directly

This study we want to do an experiment: let the virtual machine can access the Internet. The idea is to make the real machine as a router, and the virtual machine can access the Internet through the real machine as a router. Here's what you need to know

4. Network Settings Tool (One-time Settings)

ping	##Detect whether the network is unobstructed

	ifconfig	##View or set the network interface

ifconfig	##See
ifconfig device ip/24 ##Set up


In the absence of an ip, we can set it in this way: = "Note: device's name is a physical fact, what name can only be used to see what name"?==

ifconfig device down ##Close

	ifconfig device up	##open

ip addr		##Detect or configure network interfaces

	ip addr show	##Testing

ip addr add ip/24 dev device 	##Set up

ip addr fiush eth0	##Change the ip step

ip addr add ip/24 dev device

"Note: device's name is a physical fact. What name can only be used when you see it?"

5. Setting ip graphically

1.nm-connection-editor

systemctl stop NetworkManager
systemctl rstart network
systemctl start NetworkManager

6. Command Setting Network

nmcli # Network Manager must be turned on

nmcli device connect eth0 	##Enabling eth0 network card
nmcli device disconnect eth0 	##Turn off eth0 network card
nmcli device show eth0		##View Network Card Information
nmcli device status eth0	View Network Card Service Interface Information

nmcli connection show
nmcli connection down westos
nmcli connection up westos
nmcli connection delete westos
nmcli connection add type ethernet con-name westos ifname eth0 ipv4 172.25.254.66/24
nmcli connection modify westos ipv4.method auto
nmcli connection modify westos ipv4.method manual
nmcli connection modify westos ipv4.addresses 172.25.254.166/24

7. Manage network profiles

Network Configuration Directory

/etc/sysconfig/network-scripts/

Naming rules for network configuration files

ifcfg-xxx
DEVICE=XXX 	##Device name
BOOTPROTO=dhcp|static|none	##Working mode of equipment
ONBOOT=yes	##Automatic activation of network card when network service is on
IPADDR= 	##ip address
PREFIX=24	Subnet mask
NETMASK=255.255.255.0	Subnet mask
NAME=	Interface name

Example:
Static Network Settings File

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

DEVICE=eth0
BOOTPROTO=none      
ONBOOT=yes      
IPADDR=172.25.254.166         
NETMASK=255.255.255.0  
NAME=westos

systemctl restart network

One network card configures mult ip le IPS

vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none                  
ONBOOT=yes      
IPADDR0=172.25.254.166   
NETMASK0=255.255.255.0   
NAME=westos
IPADDR1=172.25.0.166
PREFIX1=24

System CTL restart network restart to make the operation effective


ip addr show eth0 view

8. Simulated experiments

A virtual machine is equipped with dual network cards to realize router function. The real machine is connected with another virtual machine which is not in the same network segment as the real machine.

Open the following interface in a real machine with the virt-manager command

This operation is to add a network card to the virtual machine, which virtual machine to add as a router to which, I am to desktop virtual machine as a router.

In desktop

vim /etc/sysctl.conf
 Open and add
net.ipv4.ip_forward=1

As shown above

firewall-cmd --list-all

Use this command to view masquerade

Change Gateway in Single Network Card Virtual Machine

route -n

Command to view the current gateway
Setting gateway to router IP in network configuration file (this IP is in the same network segment as single network card ip)

Restart the network

test

ping 170.25.254.70

This IP is a real ip, and the ping test is successful.

Topics: network vim Linux firewall