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终止

三参数与接纳

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地址刷新”逻辑将尝试的最大循环数,默许为10

    -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

ip命令详解。    -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或然IPV6)地址

    neighbour     APRADOP大概NDISC缓冲区条目

    route        路由表条目

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

    maddress     多播地址

    mroute     多播路由缓冲区条目

    monitor    监察和控制互连网新闻

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

    tunnel         IP上的康庄大道

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

留意:全数的对象名都能够简写,例如: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

    TATucsonGET为目的互连网或主机,GW为网关或吓一跳。

[[email protected]
~]# ip route add 172.16.0.0/16 via 192.168.29.1

(二)删除路由表

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

(3) 显示路由表

格式: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 实例

(一)展现网络设施的运作状态

[[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

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

[[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下较新的功效强大的互联网铺排工具。 1 功能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,从提供的公文或正式输入中读取命令并调用它们,第1回退步将导致IP终止

    -b:-batch
filenam,从提供的文件或正式输入中读取命令并调用它们,第壹回战败将促成IP终止

在两台服务器上分别实施如下命令:

三参数与选择

3参数与选用

[@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地址刷新”逻辑将尝试的最大循环数,暗中同意为10

   notification_email_from
[email protected]

    -f :-family  钦赐要选取的协议族,协议得以是3个inet,inet六、bridge, ipx, dnet or
link

    -f :-family  钦点要运用的协议族,协议能够是1个inet,inet陆、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     2个设备的商业事务(IP恐怕IPV陆)地址

    address     3个装备的情商(IP大概IPV6)地址

    }

    neighbour     A智跑P只怕NDISC缓冲区条目

    neighbour     A奥迪Q伍P或许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        隧道以太网(L二TPV三)

   
 [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

 

5 查看互连网音讯

5 查看互连网音信

 

[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:

(一)添加路由表

(一)添加路由表

在宗旨上遍布执行:

格式:ip rouite add TARGET via GW

格式:ip rouite add TARGET via GW

[@server_150 ~]# keepalived start

    TALX570GET为目的网络或主机,GW为网关或吓一跳。

    TA帕杰罗GET为对象网络或主机,GW为网关或吓一跳。

[@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 

(二)删除路由表

(二)删除路由表

    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 

(肆)清空路由表

(4)清空路由表

       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

(1)呈现互联网设施的运维状态

(一)彰显网络设施的运作意况

从机:

[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

(2)展现邻居表

(二)显示邻居表

    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 

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

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

       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)开启互连网设施

(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:1九二.168.0.一五7 vip:1玖2.168.0.50
在两台服…

相关文章