当前位置:网站首页>【无标题】
【无标题】
2022-07-03 07:04:00 【阳光大男孩MJ】
1).查询ip的几种方式: ip, ifconfig, nmcli,nmtui
ip a:
[[email protected] test]# ip a
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:5e:61:61 brd ff:ff:ff:ff:ff:ff
inet 192.168.178.128/24 brd 192.168.178.255 scope global dynamic noprefixroute ens160
valid_lft 1298sec preferred_lft 1298sec
inet6 fe80::9d7c:229c:e5e9:aac1/64 scope link noprefixroute
valid_lft forever preferred_lft forever
ifconfig:
[[email protected] test]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.178.128 netmask 255.255.255.0 broadcast 192.168.178.255
inet6 fe80::9d7c:229c:e5e9:aac1 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:5e:61:61 txqueuelen 1000 (Ethernet)
RX packets 5449 bytes 3086175 (2.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3195 bytes 245848 (240.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
nmcli:
[[email protected] test]# nmcli
ens160: connected to ens160
"VMware VMXNET3"
ethernet (vmxnet3), 00:0C:29:5E:61:61, hw, >
ip4 default
inet4 192.168.178.128/24
route4 0.0.0.0/0
route4 192.168.178.0/24
inet6 fe80::9d7c:229c:e5e9:aac1/64
route6 fe80::/64
route6 ff00::/8
nmtui:
2).nmcli命令使用:
a.在ens160网卡上新建连接static_con,并配置静态ip
[[email protected] test]# nmcli connection add type ethernet con-name static_con ifname ens160 ipv4.addresses 192.168.178.129/24 ipv4.gateway 192.168.178.2 ipv4.method manual ipv4.dns 8.8.8.8 autoconnect yes
Warning: There is another connection with the name 'static_con'. Reference the connection by its uuid 'ae07a3c9-3efc-4f17-b434-82a16c9e4caa'
Connection 'static_con' (ae07a3c9-3efc-4f17-b434-82a16c9e4caa) successfully added.
b.在ens160网卡上新建连接auto_con, 配置动态ip
[[email protected] test]# nmcli connection add type ethernet con-name auto_con ifname ens160 ipv4.method auto
Connection 'auto_con' (dccfd933-4116-4a2b-a7cf-f4dbacb31760) successfully added.
c.修改static_con的ip的方式: nmtui,nmcli c modify, nmcli c edit, 修改配置文件
nmtui:
nmcli c modify:
[[email protected] test]# nmcli c modify static_con ipv4.addr '192.168.178.129/24'
nmcli c edit:
[[email protected] test]# nmcli c edit static_con
===| nmcli interactive connection editor |===
Editing existing '802-3-ethernet' connection: 'static_con'
Type 'help' or '?' for available commands.
Type 'print' to show all the connection properties.
Type 'describe [<setting>.<prop>]' for detailed property description.
You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, dcb, sriov, ethtool, match, ipv4, ipv6, tc, proxy
nmcli> goto ipv4.addresses
nmcli ipv4.addresses> change
Edit 'addresses' value: 192.168.178.130/24
Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes
nmcli ipv4.addresses> back
nmcli ipv4> save
Connection 'static_con' (924e8830-0140-4192-984d-912b42858f12) successfully updated.
nmcli ipv4> quit
修改配置文件:
[[email protected] network-scripts]# vim ifcfg-static_con
IPADDR2=192.168.178.129
PREFIX=24
d.激活static_con的方式: up, reapply, reload, load
[[email protected] network-scripts]# nmcli c reload
e.删除static_con
[[email protected] network-scripts]# nmcli c del static_con
Connection 'static_con' (924e8830-0140-4192-984d-912b42858f12) successfully deleted.
f.添加一个网卡,并查看设备状态
[[email protected] network-scripts]# nmcli d
DEVICE TYPE STATE CONNECTION
ens160 ethernet connected ens160
virbr0 bridge connected virbr0
ens224 ethernet disconnected --
lo loopback unmanaged --
virbr0-nic tun unmanaged --
h:如果是connected,断开连接
[[email protected] network-scripts]# nmcli d disconnect ens224
Device 'ens224' successfully disconnected.
i:将断开的网卡状态设为connected
[[email protected] network-scripts]# nmcli d connect ens224
Device 'ens224' successfully activated with '27018877-beea-4fc6-af82-178a790baef1'.
[[email protected] network-scripts]# nmcli d
DEVICE TYPE STATE CONNECTION
ens160 ethernet connected ens160
ens224 ethernet connected ens224
virbr0 bridge connected virbr0
lo loopback unmanaged --
virbr0-nic tun unmanaged --
4.停止ens224连接(记得在Vmware上操作,因为停止ens160后,远程连接断掉)
删除ens224连接
[[email protected] network-scripts]# nmcli c delete ens224
Connection 'ens224' (27018877-beea-4fc6-af82-178a790
查看所有连接
[[email protected] network-scripts]# nmcli c
NAME UUID TYPE DEVICE
ens160 f2152c59-7800-4e86-b1a9-ce62a0c7590a ethernet ens160
virbr0 40475724-d97d-4ac6-9452-7f91901eae51 bridge virbr0
auto_con dccfd933-4116-4a2b-a7cf-f4dbacb31760 ethernet --
查看所有设备
[[email protected] network-scripts]# nmcli d
DEVICE TYPE STATE CONNECTION
ens160 ethernet connected ens160
virbr0 bridge connected virbr0
ens224 ethernet disconnected --
lo loopback unmanaged --
virbr0-nic tun unmanaged --
创建静态IP连接
[[email protected] network-scripts]# nmcli connection add type ethernet con-name static_con ifname ens160 ipv4.addresses 192.168.178.129/24 ipv4.gateway 192.168.178.2 ipv4.method manual ipv4.dns 8.8.8.8 autoconnect yes
[[email protected] network-scripts]# nmcli c
NAME UUID TYPE DEVICE
ens160 f2152c59-7800-4e86-b1a9-ce62a0c7590a ethernet ens160
virbr0 40475724-d97d-4ac6-9452-7f91901eae51 bridge virbr0
auto_con dccfd933-4116-4a2b-a7cf-f4dbacb31760 ethernet --
static_con c39e2aee-e999-46c3-877a-58d940dc0179 ethernet --
[[email protected] network-scripts]# nmcli c show static_con
ipv4.addresses: 192.168.178.129/24
ipv4.gateway: 192.168.178.2
启动连接
[[email protected] network-scripts]# nmcli c up static_con
使连接生效的三种方式
①
[[email protected] ~]# nmcli c up ens160
②
[[email protected] ~]# nmcli d reapply ens160
Connection successfully reapplied to device 'ens160'.
③
[[email protected] ~]# nmcli d connect ens160
Device 'ens160' successfully activated with 'f2152c59-7800-4e86-b1a9-ce62a0c7590a'.
查看创建连接所产生的配置文件
[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# ls
ifcfg-auto_con ifcfg-ens160 ifcfg-static_con
修改IP,在原先ip的基础上+10=》 比如:原IP为:192.168.233.128 =》 192.168.233.138
[[email protected] network-scripts]# nmcli c modify ens160 ipv4.addr '192.168.178.138/24'
[[email protected] network-scripts]# nmcli c show ens160
ipv4.addresses: 192.168.178.138/24
边栏推荐
- 2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)
- Inno setup production and installation package
- Advanced APL (realize group chat room)
- Summary of remote connection of MySQL
- 利用C#实现Pdf转图片
- Laravel Web框架
- [day15] introduce the features, advantages and disadvantages of promise, and how to implement it internally. Implement promise by hand
- IC_ EDA_ All virtual machine (rich Edition): questasim, vivado, VCs, Verdi, DC, Pt, spyglass, icc2, synthesize, innovative, ic617, mmsim, process library
- Jmeter+influxdb+grafana of performance tools to create visual real-time monitoring of pressure measurement -- problem record
- 10 000 volumes - Guide de l'investisseur en valeur [l'éducation d'un investisseur en valeur]
猜你喜欢

Arctic code vault contributor

4279. 笛卡尔树

Setting up the development environment of dataworks custom function

【类和对象】深入浅出类和对象
![[classes and objects] explain classes and objects in simple terms](/img/41/250457530880dfe3728432c2ccd50b.png)
[classes and objects] explain classes and objects in simple terms

Selenium key knowledge explanation

Practical plug-ins in idea

2022-06-23 vgmp OSPF inter domain security policy NAT policy (under update)

如何迁移或复制VMware虚拟机系统

Mise en place d'un environnement de développement de fonctions personnalisées
随机推荐
Arctic code vault contributor
3311. 最长算术
Unit test notes
Software testing assignment - day 3
[Fiddler actual operation] how to use Fiddler to capture packets on Apple Mobile Phones
(翻译)异步编程:Async/Await在ASP.NET中的介绍
2022 East China Normal University postgraduate entrance examination machine test questions - detailed solution
These two mosquito repellent ingredients are harmful to babies. Families with babies should pay attention to choosing mosquito repellent products
Machine learning | simple but feature standardization methods that can improve the effect of the model (comparison and analysis of robustscaler, minmaxscaler, standardscaler)
Troubleshooting of high CPU load but low CPU usage
服务器如何设置多界面和装IIS呢?甜甜给你解答!
[Code] occasionally take values, judge blanks, look up tables, verify, etc
熊市里的大机构压力倍增,灰度、Tether、微策略等巨鲸会不会成为'巨雷'?
【类和对象】深入浅出类和对象
How to specify the execution order for multiple global exception handling classes
Software testing learning - day 3
Liang Ning: 30 lectures on brain map notes for growth thinking
Thoughts on project development
[attribute comparison] defer and async
The pressure of large institutions in the bear market has doubled. Will the giant whales such as gray scale, tether and micro strategy become 'giant thunder'?