溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

第十二章 網(wǎng)絡(luò)管理-centos7.5知識

發(fā)布時間:2020-06-14 12:04:50 來源:網(wǎng)絡(luò) 閱讀:255 作者:jxwpx 欄目:安全技術(shù)

一、ip地址管理

hostnamectl set-hostname s1.test.com

nmcli general hostname s1.test.com

nmcli device status

nmcli device show ens32

nmtui

nmcli help

Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

OPTIONS

-t[erse] terse output

-p[retty] pretty output

-m[ode] tabular|multiline output mode

-f[ields] <field1,field2,...>|all|common specify fields to output

-e[scape] yes|no escape columns separators in values

-n[ocheck] don't check nmcli and NetworkManager versions

-a[sk] ask for missing parameters

-w[ait] <seconds> set timeout waiting for finishing operations

-v[ersion] show program version

-h[elp] print this help

OBJECT

g[eneral] NetworkManager's general status and operations

n[etworking] overall networking control

r[adio] NetworkManager radio switches

c[onnection] NetworkManager's connections

d[evice] devices managed by NetworkManager

注意:centos7以后網(wǎng)卡命令規(guī)則

en     以太網(wǎng)           Ethernet
wl     無線局域網(wǎng)        WLAN
×××     無線廣域網(wǎng)        WWAN
o    on-board device index number
s    hotplug slot index number
x    MAC address
p    PCI geograhical location/USB port number chain

序號由系統(tǒng)變量生成

修改為eth0樣式的方法

編輯/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”

grub2-mkconfig -o/boot/grub2/grub.cfg

命令管理

ifconfig

ifconfig eth2

ifconfig eth0 down

ifconfig eth0 up

ifconfig eth2 192.168.11.22 netmask 255.255.255.0 [ broadcast 192.168.11.255 ]

ifconfig eth0 192.168.11.10 netmask 255.255.255.0 [broadcast 255.255.255.0]

ifconfig eth0 hw ether 00:11:22:22:11:00

設(shè)置MAC地址

ifconfig eth0:1 192.168.12.23 netmask 255.255.255.0

添加子接口

ifconfig eth0 -arp

ifconfig eth0 arp

二、路由管理route

1、route -n

顯示

2、添加路由

route add -net 目標(biāo)網(wǎng)段 netmask x.x.x.x gw 下一跳路由地址

route add -net 目標(biāo)網(wǎng)段 netmask x.x.x.x dev eth2

route add -net 172.18.11.0 netmask 255.255.255.0 gw 192.168.11.23

route add -host 172.18.11.67 gw 192.168.11.23 reject (拒絕路由的操作)

route -host 目標(biāo)主機 gw 下一跳路由地址

route add -host 172.18.11.67 gw 192.168.11.23

默認(rèn)網(wǎng)關(guān)

route add default gw 網(wǎng)關(guān)地址

route del default gw 192.168.11.23

刪除路由

route del -net 172.18.11.0 netmask 255.255.255.0 gw 192.168.11.23

三、命令操作重啟丟失,永存保存的設(shè)置方法

1、把這些命令寫到/etc/rc.local;

2、更改配置文件

網(wǎng)卡:

vi /etc/sysconfig/network-scripts/ifcfg-eth[0,1,2....]

DEVICE=eth2

TYPE=Ethernet

ONBOOT=yes

BOOTPROTO=static

IPADDR=192.168.91.20

NETMASK=255.255.255.0

#GATEWAY=192.168.91.1

生效需重啟服務(wù)service network restart(注意:虛擬機要重啟機器)

vi /etc/resolv.conf

nameserver 202.106.0.20

nameserver 222.222.222.222

路由

vi /etc/sysconfig/network-scripts/route-eth[0,1,2....]

192.168.30.0/24 via 192.168.91.10 dev eth2

192.168.30.0 netmask 255.255.255.0 via 192.168.91.10 dev eth2

四、網(wǎng)絡(luò)測試的命令

ping -c 次數(shù) 172.18.199.1

traceroute 目標(biāo) 檢測路由經(jīng)過跳數(shù)

nslookup DNS檢測解析

arp -n 檢測arp解析

實驗作業(yè):

1、建立2臺LINUX服務(wù)器,第一臺有2塊網(wǎng)卡,eth0為系統(tǒng)默認(rèn)網(wǎng)卡不需要改動,eth2為192.168.學(xué)號.學(xué)號;

第二臺機器只有1塊網(wǎng)卡,默認(rèn)為DHCP,另添加ip地址,192.168.學(xué)號+100.學(xué)號。在第1臺機器上分別用動態(tài)和靜態(tài)路由添加方法,實現(xiàn)ping通第2臺機器的子接口IP。

作業(yè):

1、寫出能夠修改centos7.5IP地址的方法;

2、添加默認(rèn)網(wǎng)關(guān)的方法。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI