第三天
01 使用vm虚拟机 安装centos7系统 然后使用桥接模式 自定义ip 实战一下 如果很熟练也不用实战演示
直接把配置ip 用到配置 写到这里即可
centos 系统
cd /etc/sysconfig/network-scripts/
ls
vi ifcfg-ens160
NAME=eth0
DEVICE=eth0
BOOTPROTO=dhcp|static|none
IPADDA=10.0.0.7
PREFIX=24
ONBOOT=yes
生效
reboot
或者
nmcli connection reload
nmcli connection 看一下你的网卡名称是多少
nmcli connection up eth0
ubuntu
注意:yaml文件缩进非常严格,错一位都不行,且配置文件必须以 .yaml后缀
如果有多个ip要配置,也可以写在一个文件里
格式:
列表
[]
- 10.0.0.12 -10.0.0.13
字典
key: values addresses: 192.168.1.1/24
自动获取
network:
ethernets:
eth1:
dhcp4: true
version: 2
静态配置
cd /etc/netplan/
ls
vim 01-netcfg.yaml
network:
version:2
renderer:networkd
ethernets:
eth0:
dhcp4:no
addresses:
- 192.168.1.10/24
gateway4:192.168.1.0
nameservers:
addresses:[8.8.8.8, 114.114.114.114]
或者
network:
version:2
renderer:networkd
ethernets:
eth0:
dhcp4:no
addresses:
- 192.168.1.10/24
- 10.0.0.7/8
gateway4:10.0.0.2
nameservers:
search: [baidu.com, laowang.com]
addresses: [10.0.0.2, 117.65.64.62]
生效
reboot
或者
netplan apply
ip a
系统rocky8.5.
[root@rocky8 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:cf:f3:70 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.173/24 brd 10.0.0.255 scope global dynamic noprefixroute eth0
valid_lft 1497sec preferred_lft 1497sec
inet6 fe80::20c:29ff:fecf:f370/64 scope link
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:0f:cc:5c brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
link/ether 52:54:00:0f:cc:5c brd ff:ff:ff:ff:ff:ff
系统ubuntu2204
root@ubuntu22:/etc/netplan# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:38:c6:e1 brd ff:ff:ff:ff:ff:ff
altname enp2s1
altname ens33
inet 10.0.0.170/24 metric 100 brd 10.0.0.255 scope global dynamic eth0
valid_lft 995sec preferred_lft 995sec
inet6 fe80::20c:29ff:fe38:c6e1/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:38:c6:eb brd ff:ff:ff:ff:ff:ff
altname enp2s5
altname ens37
inet 10.0.0.174/24 metric 100 brd 10.0.0.255 scope global dynamic eth1
valid_lft 1377sec preferred_lft 1377sec
inet6 fe80::20c:29ff:fe38:c6eb/64 scope link
valid_lft forever preferred_lft forever
- 使用xshell 远程连接服务器 实战演示 会的 就不用演示了
标签:10.0,forever,00,preferred,第三天,lft,ff From: https://www.cnblogs.com/nwq1101/p/18063127