ip命令详解

By admin in 美高梅手机版4858 on 2019年4月4日

ip命令是Linux下较新的效率强大的互连网布局工具。

ip命令是Linux下较新的功效强大的网络陈设工具。

IP命令,ip命令详解

ip命令是Linux下较新的功效强大的互联网布局工具。

1 功能

ip命令用来展现或操纵Linux主机的路由、网络设施、策略路由和隧道。

2用法

Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }

ip [ -force ] -batch filename

    -force:不要甘休批处理格局中的错误

    -b:-batch
filenam,从提供的公文或正式输入中读取命令并调用它们,第二次破产将招致IP终止

3参数与选取

OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |

tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |

netns | l2tp | tcp_metrics | token }

 

OPTIONS := { -V[ersion] | -h[uman-readable] | -s[tatistics] |
-d[etails] |

-r[esolve] | -iec | -f[amily] { inet | inet6 | ipx | dnet | link }

| -4 | -6 | -I | -D | -B | -0 | -l[oops] { maximum-addr-flush-

attempts } | -o[neline] | -rc[vbuf] [size] | -t[imestamp] |

-ts[hort] | -n[etns] name | -a[ll] }

(1)OPTIONS

    是部分改动ip行为照旧变更其出口的选项,全体的选项都以以-字符起初,分为长、短二种情势:

    -V :-Version打字与印刷ip的版本并退出

    -h:    人类可读输出

     -s: -stats
–statistics,输出越来越多的消息,假诺那个选项出现五回或以上,输出的信息将特别详细

    d:输出愈多的细节新闻

    -l:钦赐”IP地址刷新”逻辑将尝试的最大循环数,私下认可为拾

    -f :-family
 钦定要利用的协议族,协议能够是三个inet,inet陆、bridge, ipx, dnet or
link

    -4: 是 -family inet的简写

    -6 :是 -family inet6的简写

    -0 :是 -family link 的简写

    -I: 是-family ipx的简写

    -o:-oneline 单行输出,用”\”字符替换换行符

    -n:-netns沟通机的IP到钦定的网络空间netns

    -r:-resolve 使用系统名称解析来打字与印刷DNS名称而不是主机地址

    -t:使用监视器选项时显妥当前时刻

    -a:-all对负有指标执行内定的吩咐,那取决于命令是或不是匡助这一个选项

    -rc:-rcvbuf (size) 设置Netlink套接字接收缓冲区的轻重缓急设置,暗中认可为1MB

(2)OBJECT

    是你要管住仍然获撤除息的目的

OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |

tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |

netns | l2tp | tcp_metrics | token }

实际表示的意义:

     link        网络设施

    address     三个设施的磋商(IP恐怕IPV陆)地址

    neighbour     A汉兰达P或然NDISC缓冲区条目

    route        路由表条目

    rule         路由政策数据库中的规则

    maddress     多播地址

ip命令详解。    mroute     多播路由缓冲区条目

    monitor    监察和控制网络新闻

    mrule        组播路由政策数据库中的规则

    tunnel         IP上的坦途

    l二tp        隧道以太网(L2TPV叁)

专注:全部的目的名都能够简写,例如:address能够简写为addr,甚至是a。

4 修改IP地址

(1)增加IP地址

格式: ip addr add ADDRESS/MASK dev DEVICE

[email protected]
~]# ip addr add 192.1.1.1/24 dev ens33

(2)删除IP地址

[[email protected]
~]# ip addr del 192.1.1.1/24 dev ens34

5 查看互联网新闻

[[email protected]
~]# ip address show

[……]

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP qlen 1000

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

inet 192.168.29.3/24 brd 192.168.29.255 scope global ens33

valid_lft forever preferred_lft forever

inet6 fe80::20c:29ff:fe3a:82/64 scope link

valid_lft forever preferred_lft forever

3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP qlen 1000

link/ether 00:0c:29:3a:00:8c brd ff:ff:ff:ff:ff:ff

inet 192.1.1.1/24 scope global ens34

valid_lft forever preferred_lft forever

inet6 fe80::20c:29ff:fe3a:8c/64 scope link tentative

valid_lft forever preferred_lft forever

陆 路由表的增进与删除

(一)添加路由表

格式:ip rouite add TARGET via GW

    TA景逸SUVGET为对象网络或主机,GW为网关或吓一跳。

[[email protected]
美高梅手机版4858,~]# ip route add 172.16.0.0/16 via 192.168.29.1

(二)删除路由表

[[email protected]
~]# ip route del 172.16.0.0/16

(三) 呈现路由表

格式:ip route show|list

[[email protected]
~]# ip route list

default via 192.168.29.1 dev ens33 proto static metric 100

172.16.0.0/16 via 192.168.29.1 dev ens33

192.168.29.0/24 dev ens33 proto kernel scope link src 192.168.29.3
metric 100

192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1

[[email protected]
~]# ip route show

default via 192.168.29.1 dev ens33 proto static metric 100

172.16.0.0/16 via 192.168.29.1 dev ens33

192.168.29.0/24 dev ens33 proto kernel scope link src 192.168.29.3
metric 100

192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1

(四)清空路由表

格式:ip route flush [dev IFACE] [via PREFIX]

[[email protected]
~]# ip route flush dev ens33

(伍)添加网关

格式:ip route add default via GW dev IFACE

[[email protected]
~]# ip route add default via 192.168.29.1

7 实例

(1)呈现互联网设施的周转意况

[[email protected]
~]# ip link list

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state
UNKNOWN mode DEFAULT qlen 1

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP mode DEFAULT qlen 1000

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

(二)显示邻居表

[[email protected]
~]# ip neigh list

192.168.29.1 dev ens33 lladdr 00:50:56:c0:00:01 REACHABLE

(叁)查看网卡音信

[[email protected]
~]# ip -s link list ens33

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP mode DEFAULT qlen 1000

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

RX: bytes packets errors dropped overrun mcast

704554 4943 0 0 0 0

TX: bytes packets errors dropped carrier collsns

470814 3110 0 0 0 0

(四)改变最大传输队列长度

[[email protected]
~]# ip link set dev ens33 txqueuelen 1500

(5)设置MTU

[[email protected]
~]# ip link set ens33 mtu 1400

来得以上设置是不是见效

[[email protected]
~]# ip link show ens33

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc
pfifo_fast state UP mode DEFAULT qlen 1500

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

能够看到mtu 和 qlen都曾经生效

(⑥)关闭网络设施

[[email protected]
~]# ip link set ens38 down

[[email protected]
~]# ip link show ens38

4: ens38: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state
DOWN mode DEFAULT qlen 1000

link/ether 00:0c:29:3a:00:96 brd ff:ff:ff:ff:ff:ff

[[email protected]
~]#

(七)开启互连网设施

[[email protected]
~]# ip link set ens38 up

[[email protected]
~]# ip link show ens38

4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP mode DEFAULT qlen 1000

link/ether 00:0c:29:3a:00:96 brd ff:ff:ff:ff:ff:ff

 

ip命令是Linux下较新的成效强大的网络安插工具。 一 作用ip命令用来展现或操纵Linux主机的路由、互联网设施、策略路由和…

keepalived配置

1 功能

1 功能

 

ip命令用来映现或操纵Linux主机的路由、互连网设施、策略路由和隧道。

ip命令用来体现或操纵Linux主机的路由、互联网设施、策略路由和隧道。

事先早已安装到位,接下去大家布置keepalived。

2用法

2用法

假若作者的ip地址如下:

Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }

Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }

server1:192.168.0.150

ip [ -force ] -batch filename

ip [ -force ] -batch filename

server2:192.168.0.157

    -force:不要结束批处理方式中的错误

    -force:不要停止批处理形式中的错误

vip:192.168.0.50

    -b:-batch
filenam,从提供的文件或规范输入中读取命令并调用它们,第一次破产将招致IP终止

    -b:-batch
filenam,从提供的文书或规范输入中读取命令并调用它们,第3次破产将造成IP终止

在两台服务器上各自实施如下命令:

三参数与选拔

三参数与选取

[@server_150 keepalived]# mkdir /etc/keepalived

OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |

OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |

[@server_150 keepalived]# cp /usr/local/keepalived/sbin/keepalived
/usr/sbin/

tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |

tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |

[@server_150 keepalived]# cp
/usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/

netns | l2tp | tcp_metrics | token }

netns | l2tp | tcp_metrics | token }

[@server_150 keepalived]# cp
/usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/

 

 

相应操作的意义:

OPTIONS := { -V[ersion] | -h[uman-readable] | -s[tatistics] |
-d[etails] |

OPTIONS := { -V[ersion] | -h[uman-readable] | -s[tatistics] |
-d[etails] |

mkdir /etc/keepalived
 ##为keepalived创设布局文件目录,暗中同意配置文件从/etc/keepalived下读取 

-r[esolve] | -iec | -f[amily] { inet | inet6 | ipx | dnet | link }

-r[esolve] | -iec | -f[amily] { inet | inet6 | ipx | dnet | link }

cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
##复制keepalived的二进制命令  

| -4 | -6 | -I | -D | -B | -0 | -l[oops] { maximum-addr-flush-

| -4 | -6 | -I | -D | -B | -0 | -l[oops] { maximum-addr-flush-

cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
 ##提供运转脚本 

attempts } | -o[neline] | -rc[vbuf] [size] | -t[imestamp] |

attempts } | -o[neline] | -rc[vbuf] [size] | -t[imestamp] |

cp /usr/local/keepalived/etc/keepalived/keepalived.conf /etc/keepalived/
##keepalived的主配置文件

-ts[hort] | -n[etns] name | -a[ll] }

-ts[hort] | -n[etns] name | -a[ll] }

编辑/etc/keepalived/keepalived.conf文件,主机修改内容如下:

(1)OPTIONS

(1)OPTIONS

! Configuration File for keepalived

    是一些修改ip行为或然改变其出口的选项,全数的选项都以以-字符开端,分为长、短二种样式:

    是一些修改ip行为只怕改变其出口的选项,全部的选项皆以以-字符开始,分为长、短二种样式:

 

    -V :-Version打字与印刷ip的本子并退出

    -V :-Version打字与印刷ip的版本并脱离

global_defs {

    -h:    人类可读输出

    -h:    人类可读输出

   notification_email {

     -s: -stats
–statistics,输出更加多的音信,若是那个选项出现四回或以上,输出的消息将尤为详细

     -s: -stats
–statistics,输出越多的消息,假使那些选项出现一回或以上,输出的信息将越发详细

   
 [email protected]

    d:输出越多的细节音讯

    d:输出越多的细节音讯

   }

    -l:钦定”IP地址刷新”逻辑将尝试的最大循环数,暗中认可为拾

    -l:内定”IP地址刷新”逻辑将尝试的最大循环数,默许为十

   notification_email_from
[email protected]

    -f :-family  内定要运用的协议族,协议得以是三个inet,inet六、bridge, ipx, dnet or
link

    -f :-family  钦点要利用的协议族,协议能够是2个inet,inet6、bridge, ipx, dnet or
link

   smtp_server 127.0.0.1

    -4: 是 -family inet的简写

    -4: 是 -family inet的简写

   smtp_connect_timeout 30

    -6 :是 -family inet6的简写

    -6 :是 -family inet6的简写

   router_id LVS_DEVEL

    -0 :是 -family link 的简写

    -0 :是 -family link 的简写

}

    -I: 是-family ipx的简写

    -I: 是-family ipx的简写

 

    -o:-oneline 单行输出,用”\”字符替换换行符

    -o:-oneline 单行输出,用”\”字符替换换行符

 

    -n:-netns沟通机的IP到钦定的网络空间netns

    -n:-netns调换机的IP到钦点的网络空间netns

vrrp_instance VI_1 {

    -r:-resolve 使用系统名称解析来打字与印刷DNS名称而不是主机地址

    -r:-resolve 使用系统名称解析来打字与印刷DNS名称而不是主机地址

    state MASTER

    -t:使用监视器选项时显示当前光阴

    -t:使用监视器选项时展示当前时间

    interface eth0

    -a:-all对拥有指标实施钦定的命令,那取决命令是还是不是扶助这一个选项

    -a:-all对具备目标执行内定的吩咐,那取决于命令是还是不是援助那一个选项

    virtual_router_id 51

    -rc:-rcvbuf (size)
设置Netlink套接字接收缓冲区的轻重缓急设置,暗中同意为1MB

    -rc:-rcvbuf (size)
设置Netlink套接字接收缓冲区的深浅设置,默许为1MB

    priority 100

(2)OBJECT

(2)OBJECT

    advert_int 1

    是您要管理依旧获裁撤息的目的

    是您要治本依旧获取新闻的目标

    authentication {

OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |

OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |

        auth_type PASS

tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |

tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |

        auth_pass 1111

netns | l2tp | tcp_metrics | token }

netns | l2tp | tcp_metrics | token }

    }

实际表示的意义:

切实表示的含义:

    virtual_ipaddress {

     link        互连网设施

     link        互联网设施

        192.168.0.50

    address     一个设施的情商(IP或然IPV六)地址

    address     二个配备的合计(IP也许IPV陆)地址

    }

    neighbour     AHummerH二P或许NDISC缓冲区条目

    neighbour     ACRUISERP也许NDISC缓冲区条目

}

    route        路由表条目

    route        路由表条目

 

    rule         路由政策数据库中的规则

    rule         路由政策数据库中的规则

从布局如下:

    maddress     多播地址

    maddress     多播地址

! Configuration File for keepalived

    mroute     多播路由缓冲区条目

    mroute     多播路由缓冲区条目

 

    monitor    监察和控制互联网音讯

    monitor    监控互连网消息

 

    mrule        组播路由政策数据库中的规则

    mrule        组播路由政策数据库中的规则

global_defs {

    tunnel         IP上的通道

    tunnel         IP上的大路

   notification_email {

    l二tp        隧道以太网(L二TPV叁)

    l二tp        隧道以太网(L2TPV叁)

   
 [email protected]

在意:全体的靶子名都能够简写,例如:address能够简写为addr,甚至是a。

只顾:全数的指标名都可以简写,例如:address能够简写为addr,甚至是a。

   }

4 修改IP地址

4 修改IP地址

   notification_email_from
[email protected]

(1)增加IP地址

(1)增加IP地址

   smtp_server 127.0.0.1

格式: ip addr add ADDRESS/MASK dev DEVICE

格式: ip addr add ADDRESS/MASK dev DEVICE

   smtp_connect_timeout 30

root@centos7 ~]# ip addr add 192.1.1.1/24 dev ens33

root@centos7 ~]# ip addr add 192.1.1.1/24 dev ens33

   router_id LVS_DEVEL

(2)删除IP地址

(2)删除IP地址

}

[root@centos7 ~]# ip addr del 192.1.1.1/24 dev ens34

[root@centos7 ~]# ip addr del 192.1.1.1/24 dev ens34

 

伍 查看互连网音讯

伍 查看网络音讯

 

[root@centos7 ~]# ip address show

[root@centos7 ~]# ip address show

vrrp_instance VI_1 {

[……]

[……]

    state BACKUP

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP qlen 1000

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP qlen 1000

    interface eth0

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

    virtual_router_id 51

inet 192.168.29.3/24 brd 192.168.29.255 scope global ens33

inet 192.168.29.3/24 brd 192.168.29.255 scope global ens33

    priority 80

valid_lft forever preferred_lft forever

valid_lft forever preferred_lft forever

    advert_int 1

inet6 fe80::20c:29ff:fe3a:82/64 scope link

inet6 fe80::20c:29ff:fe3a:82/64 scope link

    authentication {

valid_lft forever preferred_lft forever

valid_lft forever preferred_lft forever

        auth_type PASS

3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP qlen 1000

3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP qlen 1000

        auth_pass 1111

link/ether 00:0c:29:3a:00:8c brd ff:ff:ff:ff:ff:ff

link/ether 00:0c:29:3a:00:8c brd ff:ff:ff:ff:ff:ff

    }

inet 192.1.1.1/24 scope global ens34

inet 192.1.1.1/24 scope global ens34

    virtual_ipaddress {

valid_lft forever preferred_lft forever

valid_lft forever preferred_lft forever

        192.168.0.50

inet6 fe80::20c:29ff:fe3a:8c/64 scope link tentative

inet6 fe80::20c:29ff:fe3a:8c/64 scope link tentative

    }

valid_lft forever preferred_lft forever

valid_lft forever preferred_lft forever

}

陆 路由表的增进与删除

6 路由表的增加与删除

运营焦点的keepalived:

(壹)添加路由表

(1)添加路由表

在着力上分布执行:

格式:ip rouite add TARGET via GW

格式:ip rouite add TARGET via GW

[@server_150 ~]# keepalived start

    TA途胜GET为对象网络或主机,GW为网关或吓一跳。

    TARGET为目标网络或主机,GW为网关或吓1跳。

[@server_150 ~]# ip addr

[root@centos7 ~]# ip route add 172.16.0.0/16 via 192.168.29.1

[root@centos7 ~]# ip route add 172.16.0.0/16 via 192.168.29.1

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 

(二)删除路由表

(2)删除路由表

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

[root@centos7 ~]# ip route del 172.16.0.0/16

[root@centos7 ~]# ip route del 172.16.0.0/16

    inet 127.0.0.1/8 scope host lo

(3) 显示路由表

(叁) 显示路由表

    inet6 ::1/128 scope host 

格式:ip route show|list

格式:ip route show|list

       valid_lft forever preferred_lft forever

[root@centos7 ~]# ip route list

[root@centos7 ~]# ip route list

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast qlen 1000

default via 192.168.29.1 dev ens33 proto static metric 100

default via 192.168.29.1 dev ens33 proto static metric 100

    link/ether 78:2b:cb:66:44:2a brd ff:ff:ff:ff:ff:ff

172.16.0.0/16 via 192.168.29.1 dev ens33

172.16.0.0/16 via 192.168.29.1 dev ens33

    inet 192.168.0.150/24 brd 10.10.79.255 scope global eth0

192.168.29.0/24 dev ens33 proto kernel scope link src 192.168.29.3
metric 100

192.168.29.0/24 dev ens33 proto kernel scope link src 192.168.29.3
metric 100

    inet 192.168.0.50/32 scope global eth0

192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1

192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1

    inet6 fe80::7a2b:cbff:fe66:442a/64 scope link 

[root@centos7 ~]# ip route show

[root@centos7 ~]# ip route show

       valid_lft forever preferred_lft forever

default via 192.168.29.1 dev ens33 proto static metric 100

default via 192.168.29.1 dev ens33 proto static metric 100

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast qlen 1000

172.16.0.0/16 via 192.168.29.1 dev ens33

172.16.0.0/16 via 192.168.29.1 dev ens33

    link/ether 78:2b:cb:66:44:2c brd ff:ff:ff:ff:ff:ff

192.168.29.0/24 dev ens33 proto kernel scope link src 192.168.29.3
metric 100

192.168.29.0/24 dev ens33 proto kernel scope link src 192.168.29.3
metric 100

    inet 220.181.26.82/24 brd 220.181.26.255 scope global eth1

192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1

192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1

    inet6 fe80::7a2b:cbff:fe66:442c/64 scope link 

(四)清空路由表

(肆)清空路由表

       valid_lft forever preferred_lft forever

格式:ip route flush [dev IFACE] [via PREFIX]

格式:ip route flush [dev IFACE] [via PREFIX]

4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

[root@centos7 ~]# ip route flush dev ens33

[root@centos7 ~]# ip route flush dev ens33

    link/ether 78:2b:cb:66:44:2e brd ff:ff:ff:ff:ff:ff

(5)添加网关

(伍)添加网关

5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

格式:ip route add default via GW dev IFACE

格式:ip route add default via GW dev IFACE

    link/ether 78:2b:cb:66:44:30 brd ff:ff:ff:ff:ff:ff

[root@centos7 ~]# ip route add default via 192.168.29.1

[root@centos7 ~]# ip route add default via 192.168.29.1

6: sit0: <NOARP> mtu 1480 qdisc noop 

7 实例

7 实例

    link/sit 0.0.0.0 brd 0.0.0.0

(一)呈现互联网设施的运营情状

(一)显示网络设施的周转景况

从机:

[root@centos7 ~]# ip link list

[root@centos7 ~]# ip link list

[@server_157 ~]# keepalived start

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state
UNKNOWN mode DEFAULT qlen 1

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state
UNKNOWN mode DEFAULT qlen 1

[@server_157 ~]# ip addr

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP mode DEFAULT qlen 1000

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP mode DEFAULT qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

    inet 127.0.0.1/8 scope host lo

(二)突显邻居表

(贰)显示邻居表

    inet6 ::1/128 scope host 

[root@centos7 ~]# ip neigh list

[root@centos7 ~]# ip neigh list

       valid_lft forever preferred_lft forever

192.168.29.1 dev ens33 lladdr 00:50:56:c0:00:01 REACHABLE

192.168.29.1 dev ens33 lladdr 00:50:56:c0:00:01 REACHABLE

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast qlen 1000

(三)查看网卡音信

(三)查看网卡消息

    link/ether 78:2b:cb:65:7f:9f brd ff:ff:ff:ff:ff:ff

[root@centos7 ~]# ip -s link list ens33

[root@centos7 ~]# ip -s link list ens33

    inet 192.168.0.157/24 brd 10.10.79.255 scope global eth0

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP mode DEFAULT qlen 1000

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP mode DEFAULT qlen 1000

    inet6 fe80::7a2b:cbff:fe65:7f9f/64 scope link 

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

       valid_lft forever preferred_lft forever

RX: bytes packets errors dropped overrun mcast

RX: bytes packets errors dropped overrun mcast

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast qlen 1000

704554 4943 0 0 0 0

704554 4943 0 0 0 0

    link/ether 78:2b:cb:65:7f:a1 brd ff:ff:ff:ff:ff:ff

TX: bytes packets errors dropped carrier collsns

TX: bytes packets errors dropped carrier collsns

    inet 220.181.26.92/24 brd 220.181.26.255 scope global eth1

470814 3110 0 0 0 0

470814 3110 0 0 0 0

    inet6 fe80::7a2b:cbff:fe65:7fa1/64 scope link 

(四)改变最大传输队列长度

(四)改变最大传输队列长度

       valid_lft forever preferred_lft forever

[root@centos7 ~]# ip link set dev ens33 txqueuelen 1500

[root@centos7 ~]# ip link set dev ens33 txqueuelen 1500

4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

(5)设置MTU

(5)设置MTU

    link/ether 78:2b:cb:65:7f:a3 brd ff:ff:ff:ff:ff:ff

[root@centos7 ~]# ip link set ens33 mtu 1400

[root@centos7 ~]# ip link set ens33 mtu 1400

5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

显示以上设置是不是见效

来得以上设置是还是不是见效

    link/ether 78:2b:cb:65:7f:a5 brd ff:ff:ff:ff:ff:ff

[root@centos7 ~]# ip link show ens33

[root@centos7 ~]# ip link show ens33

6: sit0: <NOARP> mtu 1480 qdisc noop 

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc
pfifo_fast state UP mode DEFAULT qlen 1500

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1400 qdisc
pfifo_fast state UP mode DEFAULT qlen 1500

    link/sit 0.0.0.0 brd 0.0.0.0

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

link/ether 00:0c:29:3a:00:82 brd ff:ff:ff:ff:ff:ff

近来终止从机的keepalived服务,再一次查看主从ip addr,与地点的结果同样。

能够看来mtu 和 qlen都早就生效

能够见见mtu 和 qlen都早已生效

开发银行从机的keepalived服务,然后结束主机的keepalived服务。

(陆)关闭网络设施

(陆)关闭互连网设施

重新查看主从的ip addr

[root@centos7 ~]# ip link set ens38 down

[root@centos7 ~]# ip link set ens38 down

主机:

[root@centos7 ~]# ip link show ens38

[root@centos7 ~]# ip link show ens38

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 

4: ens38: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state
DOWN mode DEFAULT qlen 1000

4: ens38: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state
DOWN mode DEFAULT qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

link/ether 00:0c:29:3a:00:96 brd ff:ff:ff:ff:ff:ff

link/ether 00:0c:29:3a:00:96 brd ff:ff:ff:ff:ff:ff

    inet 127.0.0.1/8 scope host lo

[root@centos7 ~]#

[root@centos7 ~]#

    inet6 ::1/128 scope host 

(七)开启互联网设施

(7)开启网络设施

       valid_lft forever preferred_lft forever

[root@centos7 ~]# ip link set ens38 up

[root@centos7 ~]# ip link set ens38 up

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast qlen 1000

[root@centos7 ~]# ip link show ens38

[root@centos7 ~]# ip link show ens38

    link/ether 78:2b:cb:66:44:2a brd ff:ff:ff:ff:ff:ff

4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP mode DEFAULT qlen 1000

4: ens38: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast state UP mode DEFAULT qlen 1000

    inet 192.168.0.150/24 brd 10.10.79.255 scope global eth0

link/ether 00:0c:29:3a:00:96 brd ff:ff:ff:ff:ff:ff

link/ether 00:0c:29:3a:00:96 brd ff:ff:ff:ff:ff:ff

    inet6 fe80::7a2b:cbff:fe66:442a/64 scope link 

 

 

       valid_lft forever preferred_lft forever

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast qlen 1000

    link/ether 78:2b:cb:66:44:2c brd ff:ff:ff:ff:ff:ff

    inet 220.181.26.82/24 brd 220.181.26.255 scope global eth1

    inet6 fe80::7a2b:cbff:fe66:442c/64 scope link 

       valid_lft forever preferred_lft forever

4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

    link/ether 78:2b:cb:66:44:2e brd ff:ff:ff:ff:ff:ff

5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

    link/ether 78:2b:cb:66:44:30 brd ff:ff:ff:ff:ff:ff

6: sit0: <NOARP> mtu 1480 qdisc noop 

    link/sit 0.0.0.0 brd 0.0.0.0

从机:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

    inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast qlen 1000

    link/ether 78:2b:cb:65:7f:9f brd ff:ff:ff:ff:ff:ff

    inet 192.168.0.157/24 brd 10.10.79.255 scope global eth0

    inet 192.168.0.50/32 scope global eth0

    inet6 fe80::7a2b:cbff:fe65:7f9f/64 scope link 

       valid_lft forever preferred_lft forever

3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc
pfifo_fast qlen 1000

    link/ether 78:2b:cb:65:7f:a1 brd ff:ff:ff:ff:ff:ff

    inet 220.181.26.92/24 brd 220.181.26.255 scope global eth1

    inet6 fe80::7a2b:cbff:fe65:7fa1/64 scope link 

       valid_lft forever preferred_lft forever

4: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

    link/ether 78:2b:cb:65:7f:a3 brd ff:ff:ff:ff:ff:ff

5: eth3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

    link/ether 78:2b:cb:65:7f:a5 brd ff:ff:ff:ff:ff:ff

6: sit0: <NOARP> mtu 1480 qdisc noop 

    link/sit 0.0.0.0 brd 0.0.0.0

发觉虚ip已经从主机绑定到从机,配置测试完了。

 

从前曾经设置到位,接下去大家配备keepalived。 若是本身的ip地址如下:
server壹:19二.16八.0.150 server2:192.168.0.一5七 vip:1九贰.16八.0.50
在两台服…

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有