网络设置

1:网桥设置

网桥

1:
[kiosk@foundation11 mnt]$ cd /etc/sysconfig/network-scripts/
2:备份文件
[root@foundation11 network-scripts]# cd /mnt/
[root@foundation11 mnt]# ls
ifcfg-br0  ifcfg-enp0s25  ifcfg-Ethernet_connection_1
3:删除里面能删的,图形界面!!重新建立一个能ping通172.25.254.250
[root@foundation11 mnt]# nm-connection-editor 
[root@foundation11 mnt]# cat ifcfg-Ethernet_connection_1
HWADDR=00:21:CC:BB:C2:F3
TYPE=Ethernet
BOOTPROTO=none
IPADDR=172.25.254.11
PREFIX=24
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_PRIVACY=no
NAME="Ethernet connection 1" 
UUID=66e11d03-6d3a-4a0d-af42-965f1dc7dea3
DEVICE=enp0s25
ONBOOT=yes
4:编辑ifcfg-Ethernet_connection_1
[root@foundation11 network-scripts]# cat ifcfg-Ethernet_connection_1
BOOTPROTO=none
NAME="Ethernet connection 1"
DEVICE=enp0s25
ONBOOT=yes
BRIDGE=br0
5:编辑ifcfg-br0
[root@foundation11 network-scripts]# cat ifcfg-br0
DEVICE=br0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.11
NEATMASK=255.255.255.0
TYPE=Bridge
6:重启
[root@foundation11 network-scripts]# systemctl stop NetworkManager.service 
[root@foundation11 network-scripts]# systemctl restart network
[root@foundation11 network-scripts]# systemctl start NetworkManager
[root@foundation11 network-scripts]# brctl show
bridge name bridge id       STP enabled interfaces
br0     8000.0021ccbbc2f3   no      enp0s25
virbr0      8000.000000000000   yes     
virbr1      8000.525400084eb6   yes     virbr1-nic
7:测试virt-manager

选择Network install(HTTP,FTP,orCDROM)安装
对比效果

虚拟机桥接设计

1:进行前重置虚拟机

[root@localhost Desktop]# nm-connection-editor
[root@localhost Desktop]# brctl show #显示桥接状况
bridge name bridge id       STP enabled interfaces
[root@localhost Desktop]# brctl addbr br0  #添加br0
[root@localhost Desktop]# brctl show
bridge name bridge id       STP enabled interfaces
br0     8000.000000000000   no      
[root@localhost Desktop]# ifconfig    #查看网络
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::788f:abff:fe8d:37d4  prefixlen 64  scopeid 0x20<link>
        ether 7a:8f:ab:8d:37:d4  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 648 (648.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.25.254.240  netmask 255.255.255.0  broadcast 172.25.254.255
        inet6 fe80::5054:ff:fe00:b0a  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:00:0b:0a  txqueuelen 1000  (Ethernet)
        RX packets 1428  bytes 6473939 (6.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 464  bytes 35936 (35.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 12  bytes 976 (976.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 976 (976.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost Desktop]# ifconfig br0 172.25.254.111 netmask 255.255.255.0   ##设置ip等
[root@localhost Desktop]# ifconfig 
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.25.254.111  netmask 255.255.255.0  broadcast 172.25.254.255
        inet6 fe80::788f:abff:fe8d:37d4  prefixlen 64  scopeid 0x20<link>
        ether 7a:8f:ab:8d:37:d4  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 19  bytes 3377 (3.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.25.254.240  netmask 255.255.255.0  broadcast 172.25.254.255
        inet6 fe80::5054:ff:fe00:b0a  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:00:0b:0a  txqueuelen 1000  (Ethernet)
        RX packets 1632  bytes 6505026 (6.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 466  bytes 36118 (35.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 12  bytes 976 (976.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 12  bytes 976 (976.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

测试

[root@localhost Desktop]# ping 172.25.254.250
PING 172.25.254.250 (172.25.254.250) 56(84) bytes of data.
From 172.25.254.111 icmp_seq=1 Destination Host Unreachable
From 172.25.254.111 icmp_seq=2 Destination Host Unreachable
From 172.25.254.111 icmp_seq=3 Destination Host Unreachable
From 172.25.254.111 icmp_seq=4 Destination Host Unreachable
^C
--- 172.25.254.250 ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 2999ms
pipe 4
[root@localhost Desktop]# brctl show
bridge name bridge id       STP enabled interfaces
br0     8000.000000000000   no      
[root@localhost Desktop]# brctl addif br0 eth0    ##建立与网卡关系
[root@localhost Desktop]# brctl show
bridge name bridge id       STP enabled interfaces
br0     8000.525400000b0a   no      eth0
[root@localhost Desktop]# ping 172.25.254.250
PING 172.25.254.250 (172.25.254.250) 56(84) bytes of data.
64 bytes from 172.25.254.250: icmp_seq=1 ttl=64 time=1.05 ms
64 bytes from 172.25.254.250: icmp_seq=2 ttl=64 time=0.730 ms
64 bytes from 172.25.254.250: icmp_seq=3 ttl=64 time=0.511 ms
^C
--- 172.25.254.250 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.511/0.765/1.054/0.223 ms
[root@localhost Desktop]# 
[root@localhost Desktop]# ifconfig 
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.25.254.111  netmask 255.255.255.0  broadcast 172.25.254.255
        inet6 fe80::788f:abff:fe8d:37d4  prefixlen 64  scopeid 0x20<link>
        ether 52:54:00:00:0b:0a  txqueuelen 0  (Ethernet)
        RX packets 166  bytes 24481 (23.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 27  bytes 3881 (3.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:00:0b:0a  txqueuelen 1000  (Ethernet)
        RX packets 2449  bytes 6635335 (6.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 519  bytes 40392 (39.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 24  bytes 2192 (2.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 24  bytes 2192 (2.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@localhost Desktop]# ifconfig br0 down   #停止br0
[root@localhost Desktop]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:00:0b:0a  txqueuelen 1000  (Ethernet)
        RX packets 2534  bytes 6649309 (6.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 519  bytes 40392 (39.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 24  bytes 2192 (2.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 24  bytes 2192 (2.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost Desktop]# brctl show     ##拔除br0
bridge name bridge id       STP enabled interfaces
br0     8000.525400000b0a   no      eth0
[root@localhost Desktop]# brctl delif br0 eth0
[root@localhost Desktop]# brctl show
bridge name bridge id       STP enabled interfaces
br0     8000.000000000000   no      
[root@localhost Desktop]# brctl delbr br0
[root@localhost Desktop]# brctl show
bridge name bridge id       STP enabled interfaces
[root@localhost Desktop]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:00:0b:0a  txqueuelen 1000  (Ethernet)
        RX packets 2727  bytes 6680634 (6.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 519  bytes 40392 (39.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 152  bytes 13072 (12.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 152  bytes 13072 (12.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

双网卡设置

bonds

添加一块网卡

virt-manager

[root@localhost Desktop]# nmcli connection add type bond con-name bondtstat -antlpe | grep mysql0 ifname bond0 mode active-backup ip4 172.25.254.111/24
Error: nmcli (0.9.9.1) and NetworkManager (unknown) versions don't match. Force execution using --nocheck, but the results are unpredictable.
排错
[root@localhost Desktop]# systemctl status NetworkManager
NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled)
   Active: failed (Result: core-dump) since Thu 2017-08-10 03:17:53 EDT; 4min 42s ago
  Process: 677 ExecStart=/usr/sbin/NetworkManager --no-daemon (code=dumped, signal=SEGV)
 Main PID: 677 (code=dumped, signal=SEGV)
   CGroup: /system.slice/NetworkManager.service

Aug 10 03:17:53 localhost NetworkManager[677]: (NetworkManager:677): GLib-GO...d
Aug 10 03:17:53 localhost NetworkManager[677]: (NetworkManager:677): GLib-GO...'
Aug 10 03:17:53 localhost NetworkManager[677]: (NetworkManager:677): GLib-GO...d
Aug 10 03:17:53 localhost NetworkManager[677]: (NetworkManager:677): GLib-GO...'
Aug 10 03:17:53 localhost NetworkManager[677]: (NetworkManager:677): GLib-GO...d
Aug 10 03:17:53 localhost NetworkManager[677]: (NetworkManager:677): GLib-GO...'
Aug 10 03:17:53 localhost NetworkManager[677]: (NetworkManager:677): GLib-GO...d
Aug 10 03:17:53 localhost NetworkManager[677]: (NetworkManager:677): GLib-GO...d
Aug 10 03:17:53 localhost systemd[1]: NetworkManager.service: main process ...GV
Aug 10 03:17:53 localhost systemd[1]: Unit NetworkManager.service entered f...e.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost Desktop]# 
[root@localhost Desktop]# systemctl start NetworkManager
[root@localhost Desktop]# systemctl status NetworkManager
 NetworkManagerNetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled)
   Active: active (running) since Thu 2017-08-10 03:22:47 EDT; 2s ago
 Main PID: 4018 (NetworkManager)
   CGroup: /system.slice/NetworkManager.service
           └─4018 /usr/sbin/NetworkManager --no-daemon

Aug 10 03:22:47 localhost NetworkManager[4018]: <info> (lo): exported as /or...0
Aug 10 03:22:47 localhost NetworkManager[4018]: <info> (eth0): link connected
Aug 10 03:22:47 localhost NetworkManager[4018]: <info> (eth0): carrier is ON...)
Aug 10 03:22:47 localhost NetworkManager[4018]: <info> (eth0): new Ethernet ...)
Aug 10 03:22:47 localhost NetworkManager[4018]: <info> (eth0): exported as /...1
Aug 10 03:22:47 localhost NetworkManager[4018]: <info> (eth0): device state ...]
Aug 10 03:22:47 localhost NetworkManager[4018]: <info> (eth0): preparing device
Aug 10 03:22:47 localhost NetworkManager[4018]: <info> (eth0): device state ...]
Aug 10 03:22:47 localhost NetworkManager[4018]: <info> use BlueZ version 4
Aug 10 03:22:47 localhost NetworkManager[4018]: <info> ModemManager availabl...s
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost Desktop]# nmcli connection add type bond con-name bond0 ifname bond0 mode active-backup ip4 172.25.254.111/24
Connection 'bond0' (d82bb7b7-730a-4c85-93d1-b94c48fa53ca) successfully added.
[root@localhost Desktop]# ifconfig 
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 172.25.254.111  netmask 255.255.255.0  broadcast 172.25.254.255
        ether 3e:81:df:d4:a7:63  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:00:0b:0a  txqueuelen 1000  (Ethernet)
        RX packets 7172  bytes 7550048 (7.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 519  bytes 40392 (39.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:5a:63:73  txqueuelen 1000  (Ethernet)
        RX packets 113  bytes 21521 (21.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 504  bytes 42654 (41.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 504  bytes 42654 (41.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ping外网

[root@localhost Desktop]# ping 172.25.254.250
PING 172.25.254.250 (172.25.254.250) 56(84) bytes of data.
From 172.25.254.111 icmp_seq=1 Destination Host Unreachable
From 172.25.254.111 icmp_seq=2 Destination Host Unreachable
From 172.25.254.111 icmp_seq=3 Destination Host Unreachable
From 172.25.254.111 icmp_seq=4 Destination Host Unreachable
^C
--- 172.25.254.250 ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 2999ms
pipe 4
监控
[root@localhost Desktop]# watch -n 1 cat /proc/net/bonding/bond0 
[root@localhost Desktop]# ping 172.25.254.250
PING 172.25.254.250 (172.25.254.250) 56(84) bytes of data.
From 172.25.254.111 icmp_seq=1 Destination Host Unreachable
From 172.25.254.111 icmp_seq=2 Destination Host Unreachable
From 172.25.254.111 icmp_seq=3 Destination Host Unreachable
From 172.25.254.111 icmp_seq=4 Destination Host Unreachable
From 172.25.254.111 icmp_seq=5 Destination Host Unreachable
From 172.25.254.111 icmp_seq=6 Destination Host Unreachable
From 172.25.254.111 icmp_seq=7 Destination Host Unreachable
测试
[root@localhost Desktop]# nmcli connection add con-name eth0 ifname eth0 type bond-slave master bond0
Connection 'eth0' (83e31574-e447-43f8-ab26-f5e53a39181f) successfully added.
[root@localhost Desktop]# nmcli connection add con-name eth1 ifname eth1 type bond-slave master bond0
Connection 'eth1' (45dd5b9e-67da-4958-a3d8-0fe7d0b92800) successfully added.
[root@localhost Desktop]# ifcofig eth0 down 
[root@localhost Desktop]# nmcli connection show
[root@localhost Desktop]# nmcli connection delete eth0
删除
[root@localhost Desktop]# nmcli connection delete bond0

steam模式

1:添加

[root@localhost Desktop]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}' ip4 172.25.254.111/24
Connection 'team0' (da3e88f9-0e29-4889-b1e5-43c91c0bde62) successfully added.
[root@localhost Desktop]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:00:0b:0a  txqueuelen 1000  (Ethernet)
        RX packets 14843  bytes 9103256 (8.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 648  bytes 69381 (67.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 52:54:00:5a:63:73  txqueuelen 1000  (Ethernet)
        RX packets 5666  bytes 1122150 (1.0 MiB)
        RX errors 0  dropped 140  overruns 0  frame 0
        TX packets 79  bytes 7630 (7.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 807  bytes 73022 (71.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 807  bytes 73022 (71.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

team0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.25.254.111  netmask 255.255.255.0  broadcast 172.25.254.255
        ether 8a:52:a0:8b:4a:bb  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

监控

[root@localhost Desktop]# watch -n 1 teamdctl team0 state

添加网卡

[root@localhost Desktop]# nmcli connection add con-name eth0 ifname eth0 type team-slave master team0 
Connection 'eth0' (70ad24a5-ca38-4c0c-b185-b74e061b5e0e) successfully added.
####ping外网
[root@localhost Desktop]# ping 172.25.254.11
PING 172.25.254.11 (172.25.254.11) 56(84) bytes of data.
64 bytes from 172.25.254.11: icmp_seq=1 ttl=64 time=0.224 ms
64 bytes from 172.25.254.11: icmp_seq=2 ttl=64 time=0.184 ms
64 bytes from 172.25.254.11: icmp_seq=3 ttl=64 time=0.152 ms
64 bytes from 172.25.254.11: icmp_seq=4 ttl=64 time=0.172 ms

删除

[root@localhost Desktop]# nmcli connection delete team0 
[root@localhost Desktop]# nmcli connection delete eth0
[root@localhost Desktop]# nmcli connection delete eth1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值