linux基本网络IP自动、手动配置
Linux虛擬機(jī)添加網(wǎng)卡
方法一:
#? ?nmcli connection add type ethernet ifname eth1?con-name eth1? ? ? ???//添加網(wǎng)卡
#ifdown eth1
#ifup eth0
#ifconfig eth1
#route -n? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //查看網(wǎng)關(guān)地址
備注:云上添加網(wǎng)卡,在購買ECS時可以添加多張?zhí)摂M網(wǎng)卡(eth1、eth2)
一, 配置網(wǎng)絡(luò)(方法一)
1,查看網(wǎng)絡(luò)連接
#? nmcli connection show?
# nmcli connetion show "連接名"
eg:
#nmcli con show "System eth0"
2,配置網(wǎng)絡(luò)
# nmcli connetion modify "連接名"? 參數(shù)1? ?值1 ... ...
#nmcli con mod "System eth0 " ipv4.method manual ipv4.addresses "172.25.0.11/24 172.25.0.254" ipv4.dns 8.8.8.8 connection.autoconnect yes
3,激活/禁用網(wǎng)絡(luò)連接
#nmcli conection down? "連接名"
#nmcli connection up "連接名"
4,為本機(jī)指定DNS服務(wù)器
#vim? /etc/resolv.conf
nameserver 8.8.8.8
5,配置靜態(tài)主機(jī)名
或者
?# hostnamectl set-hostname mysql
二,配置網(wǎng)絡(luò)(方法二)
===============================================================================================
Linux開機(jī)自動獲取IP
linux系統(tǒng)默認(rèn)是沒有開啟網(wǎng)絡(luò)服務(wù)的,每次開機(jī)需要手動來獲取IP。
方法一: 用命令行開啟網(wǎng)絡(luò)服務(wù)
#?systemctl restart network
#?chkconfig --level 2345 network on? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //設(shè)置開機(jī)自啟
方法二: 有桌面的設(shè)置
網(wǎng)絡(luò)連接---------》 System eth0 -----------> 將自動連接勾上
總結(jié)
以上是生活随笔為你收集整理的linux基本网络IP自动、手动配置的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 安装RHEL7系统
- 下一篇: linux命令的基本操作