linnux命令 - brctl和ifconfig
1.安装brctl
centos7.6安装使用
yum install bridge-utils
ubuntu使用
apt-get install bridge-utils
什么是网桥
网桥是一种在链路层实现中继,对帧进行转发的技术,根据MAC分区块,可隔离碰撞,将网络的多个网段在数据链路层连接起来的网络设备。
Linux网桥配置命令:brctl
[root@guanbin-k8s-node sbin]# brctl -help
Usage: brctl [commands]
commands:
addbr <bridge> add bridge
delbr <bridge> delete bridge
addif <bridge> <device> add interface to bridge
delif <bridge> <device> delete interface from bridge
hairpin <bridge> <port> {on|off} turn hairpin on/off
setageing <bridge> <time> set ageing time
setbridgeprio <bridge> <prio> set bridge priority
setfd <bridge> <time> set bridge forward delay
sethello <bridge> <time> set hello time
setmaxage <bridge> <time> set max message age
setpathcost <bridge> <port> <cost> set path cost
setportprio <bridge> <port> <prio> set port priority
show [ <bridge> ] show a list of bridges
showmacs <bridge> show a list of mac addrs
showstp <bridge> show bridge stp info
stp <bridge> {on|off} turn stp on/off
Usage: brctl [commands]
commands:
|
addbr |
<bridge> |
add bridge |
|
delbr |
<bridge> |
delete bridge |
|
addif |
<bridge> <device> |
add interface to bridge |
|
delif |
<bridge> <device> |
delete interface from bridge |
|
setageing |
<bridge> <time> |
set ageing time |
|
setbridgeprio |
<bridge> <prio> |
set bridge priority |
|
setfd |
<bridge> <time> |
set bridge forward delay |
|
sethello |
<bridge> <time> |
set hello time |
|
setmaxage |
<bridge> <time> |
set max message age |
|
setpathcost |
<bridge> <port> <cost> |
set path cost |
|
setportprio |
<bridge> <port> <prio> |
set port priority |
|
show |
show a list of bridges |
|
|
showmacs |
<bridge> |
show a list of mac addrs |
|
showstp |
<bridge> |
show bridge stp info |
|
stp |
<bridge> {on|off} |
turn stp on/off |
增加网桥
[inbi@debian~]#brctl addbr br0
#增加一个网桥
[inbi@debian~]#ifconfig eth0 0.0.0.0 promisc [inbi@debian~]#ifconfig eth1 0.0.0.0 promisc [inbi@debian~]#brctl addif br0 eth0 eth1
#将两块已有的网卡添加到网桥,此时这两个网卡工作于混杂模式,所以不需要IP了,因为网桥是工作在链路层的。
[inbi@debian~]#brctl show
#查看已有网桥
你也可以为 br0 设置一个IP,已访问这台机器。
[inbi@debian~]#ifconfig br0 10.10.1.1 netmask 255.255.0.0 up
删除网桥
[inbi@debian~]#brctl delif br0 eth0 eth1
#增加网桥中的接口
[inbi@debian~]#brctl delbr br0
#删除网桥
[inbi@debian~]#brctl stp br0 off
#关闭生成树协议,减少数据包污染,因为我这里只有一个路由器哦!
[inbi@debian~]#echo "modprobe bridge">>/etc/rc.local
#开机加载 bridge 模块,或者echo "bridge">>/etc/modules
[inbi@debian~]#cp /etc/network/interfaces /etc/network/interfaces.default
#备份下,方便以后使用啊!
[inbi@debian~]#vim /etc/network/interfaces auto lo eth0 eth1 br0 iface lo inet loopback iface br0 inet static address 10.10.10.1 netmask 255.255.0.0 gateway 10.10.10.254 pre-up ip link set eth0 promisc on pre-up ip link set eth1 promisc on pre-up echo "1">/proc/sys/net/ipv4/ip_forward bridge_ports eth0 eth1
#配置eth0 eth1 br0开机启动,eth0,eth1未设置IP信息,在启动br0网卡时,开启了eth0,eth1的混杂模式,并桥接了它们。
2.安装ifconfig
- Linux ifconfig命令用于显示或设置网络设备。
- ifconfig可设置网络设备的状态,或是显示目前的设置。
yum install net-tools
ifconfig -help
[root@guanbin-k8s-node sbin]# ifconfig -help
Usage:
ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
[add <address>[/<prefixlen>]]
[del <address>[/<prefixlen>]]
[[-]broadcast [<address>]] [[-]pointopoint [<address>]]
[netmask <address>] [dstaddr <address>] [tunnel <address>]
[outfill <NN>] [keepalive <NN>]
[hw <HW> <address>] [mtu <NN>]
[[-]trailers] [[-]arp] [[-]allmulti]
[multicast] [[-]promisc]
[mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]
[txqueuelen <NN>]
[[-]dynamic]
[up|down] ... <HW>=Hardware Type.
List of possible hardware types:
loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP)
slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP)
ash (Ash) ether (Ethernet) ax25 (AMPR AX.25)
netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel)
ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB)
arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device)
sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI)
irda (IrLAP) ec (Econet) x25 (generic X.25)
infiniband (InfiniBand) eui64 (Generic EUI-64)
<AF>=Address family. Default: inet
List of possible address families:
unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6)
ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE)
ipx (Novell IPX) ddp (Appletalk DDP) ec (Econet)
ash (Ash) x25 (CCITT X.25)
参数说明:
- add<地址> 设置网络设备IPv6的IP地址。
- del<地址> 删除网络设备IPv6的IP地址。
- down 关闭指定的网络设备。
- <hw<网络设备类型><硬件地址> 设置网络设备的类型与硬件地址。
- io_addr<I/O地址> 设置网络设备的I/O地址。
- irq<IRQ地址> 设置网络设备的IRQ。
- media<网络媒介类型> 设置网络设备的媒介类型。
- mem_start<内存地址> 设置网络设备在主内存所占用的起始地址。
- metric<数目> 指定在计算数据包的转送次数时,所要加上的数目。
- mtu<字节> 设置网络设备的MTU。
- netmask<子网掩码> 设置网络设备的子网掩码。
- tunnel<地址> 建立IPv4与IPv6之间的隧道通信地址。
- up 启动指定的网络设备。
- -broadcast<地址> 将要送往指定地址的数据包当成广播数据包来处理。
- -pointopoint<地址> 与指定地址的网络设备建立直接连线,此模式具有保密功能。
- -promisc 关闭或启动指定网络设备的promiscuous模式。
- [IP地址] 指定网络设备的IP地址。
- [网络设备] 指定网络设备的名称。
示例
显示网络设备
# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:0A:0B:0C
inet addr:192.168.0.3 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe0a:b0c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:172220 errors:0 dropped:0 overruns:0 frame:0
TX packets:132379 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:87101880 (83.0 MiB) TX bytes:41576123 (39.6 MiB)
Interrupt:185 Base address:0x2024 lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:2022 errors:0 dropped:0 overruns:0 frame:0
TX packets:2022 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2459063 (2.3 MiB) TX bytes:2459063 (2.3 MiB)
启动关闭指定网卡
# ifconfig eth0 down
# ifconfig eth0 up
为网卡配置和删除IPv6地址
# ifconfig eth0 add 33ffe:3240:800:1005::2/ 64 //为网卡设置IPv6地址 # ifconfig eth0 del 33ffe:3240:800:1005::2/ 64 //为网卡删除IPv6地址
用ifconfig修改MAC地址
# ifconfig eth0 down //关闭网卡
# ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE //修改MAC地址
# ifconfig eth0 up //启动网卡
# ifconfig eth1 hw ether 00:1D:1C:1D:1E //关闭网卡并修改MAC地址
# ifconfig eth1 up //启动网卡
配置IP地址
# ifconfig eth0 192.168.1.56
//给eth0网卡配置IP地址
# ifconfig eth0 192.168.1.56 netmask 255.255.255.0
// 给eth0网卡配置IP地址,并加上子掩码
# ifconfig eth0 192.168.1.56 netmask 255.255.255.0 broadcast 192.168.1.255
// 给eth0网卡配置IP地址,加上子掩码,加上个广播地址
启用和关闭ARP协议
# ifconfig eth0 arp //开启
# ifconfig eth0 -arp //关闭
设置最大传输单元
# ifconfig eth0 mtu 1500
//设置能通过的最大数据包大小为 1500 bytes
参考:https://www.runoob.com/linux/linux-comm-ifconfig.html
https://www.cnblogs.com/lsgxeva/p/8622870.html
linnux命令 - brctl和ifconfig的更多相关文章
- linux命令netstat或ifconfig未找到
linux命令netstat或ifconfig未找到 linux使用netstat或者ifconfig命令时,显示命令未找到.通过yum search netstat这个命令,匹配结果如下:===== ...
- Linux下的ip命令,除了ifconfig还有很多
linux的ip命令和ifconfig类似,但前者功能更强大,并旨在取代后者.使用ip命令,只需一个命令,你就能很轻松地执行一些网络管理任务.ifconfig是net-tools中已被废弃使用的一个命 ...
- linux笔记:网络命令ping,traceroute,ifconfig,netstat;挂载和卸载命令mount,umount
命令名称:ping功能:测试网络连通性命令所在路径:/bin/ping用法:ping [-c] IP地址参数:-c 指定发送次数 命令名称:ifconfig功能:查看和设置网卡信息(临时设置)命令所在 ...
- Centos7 Minni 安装 执行ifconfig命令出现 -bash ifconfig command not found 的解决方法
1) have a root privilege shell or be on the sudo list. 2a) At a root shell prompt (#) yum install ne ...
- Linnux命令大全(vim)
vim复制和粘贴的基本命令(注:需先退出编辑模式) yy复制游标所在行整行.或大写一个Y. (常用) 2yy或y2y复制两行. (常用) y^复制至行首,或y0.不含游标所在处字元. ...
- Linux 网桥配置命令:brctl
Linux网关模式下将有线LAN和无线LAN共享网段实现局域网内互联: 思路其实很简单:就是将虚拟出一个bridge口,将对应的有线LAN和无线LAN都绑定在这个虚拟bridge口上,并给这个brid ...
- centos7中没有安装ifconfig命令的解决方法
初装centos 7时,运行config报 command not found 错误,我在网上找了大量资料,下面的资料中查找原因和解决方式最详细,能很好的解决这个问题. ifconfig命令是设置或显 ...
- 每天一个linux命令(52):ifconfig命令
许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...
- 每天一个linux命令(44):ifconfig命令
许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口配置信息并对此进行修改.Linux系统拥有一个类似的工具,也就是ifconfig(interfaces config).通常需 ...
随机推荐
- SNGAN
目录 概 主要内容 Miyato T., Kataoka T., Koyama M & Yoshida Y. SPECTRAL NORMALIZATION FOR GENERATIVE ADV ...
- [opencv]拼接合并轮廓集合mergeContours
/** * 拼接合并轮廓集合 * @param contours * @return */ vector<vector<Point>> mergeContours(vector ...
- 比例阀驱动电路后级PWM滤波尖刺如何消除?PWM通过RC低通滤波器模拟DAC
双头比例阀驱动电路,采用单片机输出2路PWM,分别驱动功率器件(U100的2和4脚),经过U100的8和10脚输出供电电源的高压PWM波形,这个高压PWM经过R104和R114分别采样后经过电流放大器 ...
- MySQL数据库基础(1)数据库基础
目录 一.数据库简介 二.mysql数据库 三.客户端连接mysql服务 四.Navicat for mysql 一.数据库简介 1.概念 (1)数据:如文字.图形.图像.声音以及学生的档案记录等,这 ...
- 【MySQL作业】DDL 和 DML——美和易思使用 DDL 定义数据库表结构应用习题
点击打开所使用到的数据库>>> 1.使用 DDL 创建 easyShopping2 数据库. create database easyShopping2 2.使用 DDL 更改 ea ...
- linux(CentOS7) 之 ntp时间同步配置步骤
下 载 百度搜索 ntp rpm 下载(或直接进入官网https://pkgs.org/download/ntp) 搜多ntp,选择centos7 64位下载,ntpdata 是依赖包也要下载 基 础 ...
- 初识python: 多态
多态:允许你将父对象设置成为,与一个或更多其子对象相等的技术,赋值之后,父对象就可以根据当前赋值给它的子对象的特性以不同的方式运作. 简单讲就是:允许将子类类型的指针赋值给父类类型的指针. 多态 ...
- Appium之xpath定位详解
前面也说过appium也是以webdriver为基的,对于元素的定位也基本一致,只是增加一些更适合移动平台的独特方式,下面将着重介绍xpath方法,这应该是UI层元素定位最强大的方法啦! 以淘宝app ...
- Linux系统使用SSH登录之前如何显示横幅消息
OpenSSH有一个名为Banner的内置选项.在允许身份验证之前,将指定文件的内容发送给远程用户.如果Banner选项设置为none,那么在ssh登录时就不会显示任何Banner消息.默认情况下,不 ...
- [转]Vue之引用第三方JS插件
1.绝对路径引入,全局使用. 在index.html文件中使用script标签引入插件. 该种方式就是上面演示ckplayer插件使用的方式. 备注: 这种方式的引用,会在开启ESLint时,报错,可 ...