linux基本网络配置

版权声明:观极著作 https://blog.csdn.net/weixin_41619143/article/details/88582676

Linux虚拟机添加网卡

方法一:

#   nmcli connection add type ethernet ifname eth1 con-name eth1         //添加网卡

#ifdown eth1
#ifup eth0
#ifconfig eth1
#route -n                                                                                            //查看网关地址

备注:云上添加网卡,在购买ECS时可以添加多张虚拟网卡(eth1、eth2)

一, 配置网络(方法一)

1,查看网络连接

#  nmcli connection show 

# nmcli connetion show "连接名"

eg:

#nmcli con show "System eth0"

2,配置网络

# nmcli connetion modify "连接名"  参数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,激活/禁用网络连接

#nmcli conection down  "连接名"

#nmcli connection up "连接名"

4,为本机指定DNS服务器

#vim  /etc/resolv.conf

nameserver 8.8.8.8

5,配置静态主机名

或者

 # hostnamectl set-hostname mysql

二,配置网络(方法二)

  1. # cd /etc/sysconfig/network-scripts
  2. # cp ifcfg-eth0 ifcfg-eth1
  3. # vim ifcfg-eth1
  4. DEVICE="eth1"
  5. ONBOOT="yes"
  6. IPV6INIT="no"
  7. IPV4_FAILURE_FATAL="no"
  8. NM_CONTROLLED="no"
  9. TYPE="Ethernet"
  10. BOOTPROTO="static"
  11. IPADDR="192.168.2.1"
  12. PREFIX=24
  13. GATEWAY=192.168.1.254
  14. # systemctl restart network

===============================================================================================

猜你喜欢

转载自blog.csdn.net/weixin_41619143/article/details/88582676