查看需要配置的網(wǎng)卡名
ip address
編輯網(wǎng)卡配置文件/etc/network/interfaces
vi /etc/network/interfaces
添加以下字段為ens33這張網(wǎng)卡添加192.168.1.2這IP地址
auto ens33
iface ens33 inet static
address 192.168.1.2/24 #主機(jī)地址/掩碼
gateway 192.168.1.1 #網(wǎng)關(guān)
添加DNS服務(wù)器地址
echo >> /etc/resolv.conf nameserver 8.8.8.8
echo >> /etc/resolv.conf nameserver 1.1.1.1
重啟網(wǎng)卡、查看網(wǎng)卡IP配置情況
/etc/init.d/networking restart
ip address
允許root用戶遠(yuǎn)程登錄、重啟ssh服務(wù)
echo PermitRootLogin yes >> /etc/ssh/sshd_config
/etc/init.d/ssh restart