Network multi-method multi-mode setup and gateway configuration

ipv4

2. Hexadecimal 32-bit - decimal

172.25.0.10/255.255.255.0

172.25.0.10: ip address

255.255.255.0: subnet mask

The ip bit corresponding to the 255-bit subnet mask is the network bit

The ip bit corresponding to subnet mask 0 is the host bit

set ip

Graphical settings

1. Graphical interface

nm-connection-editor

 

After running this command, a graphical interface will appear

 

 

After entering, select dhcp as dynamic ip settings

 

 

 

dynamic ip

 

 

Select manual to set static ip

 

 

static ip

 

 

2. Text ip settings

nmtui

 

 

After entering, press the tab key to select

 

 

 

device fill in eth0

 

 

Select Automatic to set dynamic ip

 

 

 

 

 

 

 

dynamic ip

 

 

device also fill in eth0

 

 

select manual

Fill in the address 172.25.254.101/24

static ip can be set

 

 

 


 

 

 

 

3. Temporarily set ip (invalid after restart)

ifconfig device ip            netmask 255.255.255.0

ifconfig eth0 172.25.254.11   netmask  255.255.255.0

 

 

 

 

 

after reboot

 

 

systemctl restart network (restart)

 

It can be seen that the ip changes to 172.25.254.101 after restarting

 

 

 

 

4. nmcli settings

 

 

nmcli device status shows eth0 status

 

 

 

 

nmcli decice show show eth0 details

 

 

nmcli device disconnect eth0 close eth0  

 

 

 

nmcli device connect eth0 open eth0

 

 

 

 

 

 

nmcli connection ....

nmcli connection down hello close

 

 

 

nmcli connection up hello open

 

 

 

nmcli connection show hello View details

 

 

 

nmcli connection delete hello delete

 

 

 

 

 

nmcli connection add type ethernet con-name hello ifname eth0 autoconnect yes set dynamic ip

 

 

 

nmcli connection add type ethernet con-name hello ifname eth0 ip4 172.25.254.101/24 set static ip

 

 

static--------->dhcp static to dynamic

 

nmcli connection modify hello ipv4.method auto

 

systemctl restart network

 

 

 

 

dhcp------>static change dynamic network to static

nmcli connection modify hello ipv4.addresses 172.25.254.101/24

nmcli connection modify hello ipv4.method manual                 

systemctl restart network

 

 

 

 

change ip

nmcli connection modify hello ipv4.addresses 172.25.254.102/24

systemctl restart network

 

 

 

5. Edit the configuration file

cd /etc/sysconfig/network-scripts/

vim ifcfg-xxxx

 

 

DEVICE=NIC

ONBOOT=yes

BOOTPROTO=dhcp| none|static

IPADDR=ip

NETMASK=subnet mask|PREFIX=subnet mask abbreviation

[NAME=connection name]

 

 

 

 

DHCP dynamic

cd /etc/sysconfig/network-scripts/

vim ifcfg-hello


DEVICE=eth0

ONBOOT=yes

BOOTPROTO=dhcp

 

systemctl restart network

 

 

static network

 

 

cd /etc/sysconfig/network-scripts/

vim ifcfg-hello


DEVICE=eth0

ONBOOT=yes

BOOTPROTO=none

IPADDR=172.25.254.136

NETMASK=255.255.255.0 | PREFIX=24

 


systemctl restart network

 

 

A static network card to set multiple ip

cd /etc/sysconfig/network-scripts/

vim ifcfg-hello

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=none

IPADDR0=172.25.254.136

PREFIX0=24

IPADDR1=172.25.0.136

PREFIX1=24

 

 

 

systemctl restart network

ip addr show eth0

 

gateway

 

1. Gateway

The ip on the router that is on the same network segment as yourself

 

2. Set the gateway

 

systemctl stop     NetwrokManager


vim /etc/sysconfig/network ##Global gateway

GATEWAY=gateway ip

 

vim /etc/sysconfig/network-scripts/ifcfg-network card configuration file##network card interface gateway

GATEWAY=gateway ip

 

systemctl restart netwrok

 

route -n ##Query gateway

ping


ping real machine ip


Smart parsing

vim /etc/resolv.conf

 

add in it

nameserver 114.114.114.114




Real machine: switch super user --> set gateway --> restart network --> connect to wifi --> view gateway --> ping  www.baidu.com

Virtual machine: set gateway --> restart network --> DNS --> view gateway --> ping  www.baidu.com


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325970404&siteId=291194637