centos7修改網絡卡名稱、網絡卡雙網絡卡繫結
阿新 • • 發佈:2018-12-29
Linux系統在大多數企業運用中都佔據著及其重要的作用,但是從centos7開始我們發現安裝完作業系統後,網絡卡名稱發生了變化,不在是以前的eth0這樣命名了。這對於我們使用起來有很多的不便。
本文將介紹如何修改網絡卡名稱,及雙網絡卡繫結。
[[email protected] ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:84:ec:d4 brd ff:ff:ff:ff:ff:ff inet 192.168.12.143/24 brd 192.168.12.255 scope global dynamic ens33 valid_lft 1460sec preferred_lft 1460sec inet6 fe80::43b6:8da1:941c:76a8/64 scope link valid_lft forever preferred_lft forever
先修改網絡卡配置檔案
[[email protected] ~]# cd /etc/sysconfig/network-scripts/ [[email protected] network-scripts]# ls ifcfg-ens33 ifdown-isdn ifup ifup-plip ifup-tunnel ifcfg-lo ifdown-post ifup-aliases ifup-plusb ifup-wireless ifdown ifdown-ppp ifup-bnep ifup-post init.ipv6-global ifdown-bnep ifdown-routes ifup-eth ifup-ppp network-functions ifdown-eth ifdown-sit ifup-ib ifup-routes network-functions-ipv6 ifdown-ib ifdown-Team ifup-ippp ifup-sit ifdown-ippp ifdown-TeamPort ifup-ipv6 ifup-Team ifdown-ipv6 ifdown-tunnel ifup-isdn ifup-TeamPort [
[email protected] network-scripts]# mv ifcfg-ens33 ifcfg-eth0 [[email protected] network-scripts]# vim ifcfg-eth0 TYPE="Ethernet" BOOTPROTO="dhcp" DEFROUTE="yes" PEERDNS="yes" PEERROUTES="yes" IPV4_FAILURE_FATAL="no" NAME="eth0" UUID="18a685ec-ff6b-4a8f-be99-cfe597ada858" DEVICE="eth0" ONBOOT="yes"
禁用命名規則
[[email protected] network-scripts]# vim /etc/default/grub
GRUB_CMDLINE_LINUX="rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb net.ifnames=0 biosdevname=0 quiet"
[[email protected] network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-514.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-cd5074a9e6784fceb326c45e4293f6a2
Found initrd image: /boot/initramfs-0-rescue-cd5074a9e6784fceb326c45e4293f6a2.img
done
重啟
[[email protected] network-scripts]# reboot
[[email protected] network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:84:ec:d4 brd ff:ff:ff:ff:ff:ff
inet 192.168.12.143/24 brd 192.168.12.255 scope global dynamic eth0
valid_lft 1118sec preferred_lft 1118sec
inet6 fe80::20c:29ff:fe84:ecd4/64 scope link
valid_lft forever preferred_lft forever
二、配置雙網絡卡鏈路聚合
[[email protected] ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}'
Connection 'team0' (711bde84-1a1d-4aa2-a155-273d0110c031) successfully added.
新增IP
[[email protected] ~]# nmcli connection modify team0 ipv4.addresses "192.168.122.4/24" ipv4.method manual
新增閘道器、DNS
[[email protected] ~]# nmcli connection modify team0 ipv4.gateway "192.168.12.2" ipv4.dns "114.114.114.114"
[[email protected] ~]# nmcli connection add type team-slave con-name team0-p1 ifname eth0 master team0
Connection 'team0-p1' (2f281758-344a-4dc1-8204-67ff9c66f4b6) successfully added
[[email protected] ~]# nmcli connection add type team-slave con-name team0-p2 ifname eth1 master team0
Connection 'team0-p2' (2a5e5242-32b9-49ec-ae6a-a4e4c2366e7e) successfully added.
[[email protected] ~]# nmcli connection up team0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)
[[email protected] ~]# nmcli connection up team0-p1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[[email protected] ~]# nmcli connection up team0-p2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
[[email protected] ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:84:ec:d4 brd ff:ff:ff:ff:ff:ff
inet 192.168.12.143/24 brd 192.168.12.255 scope global dynamic eth0
valid_lft 1745sec preferred_lft 1745sec
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
link/ether 52:54:00:54:55:bb brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
link/ether 52:54:00:54:55:bb brd ff:ff:ff:ff:ff:ff
5: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:84:ec:de brd ff:ff:ff:ff:ff:ff
inet 192.168.12.144/24 brd 192.168.12.255 scope global dynamic eth1
valid_lft 1749sec preferred_lft 1749sec
8: team0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000
link/ether 9e:11:f7:2a:58:35 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.4/24 brd 192.168.122.255 scope global team0
valid_lft forever preferred_lft forever