当前位置:首页 » 币种行情 » ifconfigeth2设置路由

ifconfigeth2设置路由

发布时间: 2022-08-14 09:29:01

⑴ 如何设置路由模拟软件中PC机的IP地址

首先打开路由仿真软件,然后添加一台计算机
添加设备-->添加一个PC机法二:点击工具栏下方的“计算机”图标,在视图上添加一台计算机
视图上出现一台PC机
双击视图中的计算机HostA,进入终端操作
输入用户名和口令(通俗讲就是账号与密码)一般默认PCA
login:root
Password:linux
完成上一步后,就可以设置IP输入“ifconfig
eth0
192.168.1.1
netmask
255.255.255.0”然后回车设置就完成了
再回到视图里,就可以看到计算机已经显示了你设置的IP了

⑵ 华为交换机如何配置路由

家里已经有一台有线路由器,虽能满足家里的台式电脑的有线上网需求,但是无法满足手机、平板、笔记本等设备的无线上网需求。您可以将您的华为路由当做无线交换机使用。
连接线缆:用网线将路由器的任意网口连接到旧路由器的 LAN 接口。接通电源。
电脑连接到路由器的另一个网口(或电脑连接到路由器的 Wi-Fi)。在浏览器地址栏中输入 192.168.3.1 登录路由器的 Web 配置界面。
进入我要上网页面。在上网方式中选择 Bridge (AP)。点击保存。
若您是首次配置路由器,则需要电脑进入路由器配置页面,安装方式选择添加到现有网络,组网方式选择有线组网,已连接,设置路由器的 Wi-Fi名称、Wi-Fi密码和登录密码(可将Wi-Fi密码作为路由器的登录密码),路由器配置完成后,即桥接成功,您的路由器已经与旧路由器搭配成为无线交换机了。
完成设置后,您的路由器已经成为了无线交换机,手机、平板、笔记本等无线设备,可以连接到路由器 的 Wi-Fi 上网了。

⑶ 华为网关配置命令

方法:
华为路由器交换机配置命令:计算机命令

PCAlogin:root;使用root用户

password:linux;口令是linux

#shutdown-hnow;关机

#init0;关机

#logout;用户注销

#login;用户登录

#ifconfig;显示IP地址

#ifconfigeth0netmask;设置IP地址

#ifconfigeht0netmaskdown;禁用IP地址

#routeadd0.0.0.0gw;设置网关

#routedel0.0.0.0gw;删除网关

#routeadddefaultgw;设置网关

#routedeldefaultgw;删除网关

#route;显示网关

#ping;发ECHO包

#telnet;远程登录

华为路由器交换机配置命令:交换机命令

[Quidway]discur;显示当前配置

[Quidway]displaycurrent-configuration;显示当前配置

[Quidway]displayinterfaces;显示接口信息

[Quidway]displayvlanall;显示路由信息

[Quidway]displayversion;显示版本信息

[Quidway]superpassword;修改特权用户密码

[Quidway]sysname;交换机命名

[Quidway]interfaceethernet0/1;进入接口视图

[Quidway]interfacevlanx;进入接口视图

[Quidway-Vlan-interfacex]ipaddress10.65.1.1255.255.0.0;配置VLAN的IP地址

[Quidway]iproute-static0.0.0.00.0.0.010.65.1.2;静态路由=网关

[Quidway]rip;三层交换支持

[Quidway]local-userftp

[Quidway]user-interfacevty04;进入虚拟终端

[S3026-ui-vty0-4]authentication-modepassword;设置口令模式

[S3026-ui-vty0-4]setauthentication-modepasswordsimple222;设置口令

[S3026-ui-vty0-4]userprivilegelevel3;用户级别

[Quidway]interfaceethernet0/1;进入端口模式

[Quidway]inte0/1;进入端口模式

[Quidway-Ethernet0/1]plex{halffullauto};配置端口工作状态

[Quidway-Ethernet0/1]speed{10100auto};配置端口工作速率

[Quidway-Ethernet0/1]flow-control;配置端口流控

[Quidway-Ethernet0/1]mdi{acrossautonormal};配置端口平接扭接

[Quidway-Ethernet0/1]portlink-type{trunkaccesshybrid};设置端口工作模式

[Quidway-Ethernet0/1]portaccessvlan3;当前端口加入到VLAN

[Quidway-Ethernet0/2]porttrunkpermitvlan{IDAll};设trunk允许的VLAN

[Quidway-Ethernet0/3]porttrunkpvidvlan3;设置trunk端口的PVID

[Quidway-Ethernet0/1]undoshutdown;激活端口

[Quidway-Ethernet0/1]shutdown;关闭端口

[Quidway-Ethernet0/1]quit;返回

[Quidway]vlan3;创建VLAN

[Quidway-vlan3]portethernet0/1;在VLAN中增加端口

[Quidway-vlan3]porte0/1;简写方式

[Quidway-vlan3]portethernet0/1toethernet0/4;在VLAN中增加端口

[Quidway-vlan3]porte0/1toe0/4;简写方式

[Quidway]monitor-port;指定镜像端口

[Quidway]portmirror;指定被镜像端口

[Quidway]portmirrorint_listobserving-portint_typeint_num;指定镜像和被镜像

[Quidway]descriptionstring;指定VLAN描述字符

[Quidway]description;删除VLAN描述字符

[Quidway]displayvlan[vlan_id];查看VLAN设置

[Quidway]stp{enabledisable};设置生成树,默认关闭

[Quidway]stppriority4096;设置交换机的优先级

[Quidway]stproot{primarysecondary};设置为根或根的备份

[Quidway-Ethernet0/1]stpcost200;设置交换机端口的花费

[Quidway]link-aggregatione0/1toe0/4ingressboth;端口的聚合

[Quidway]undolink-aggregatione0/1all;始端口为通道号

[SwitchA-vlanx]isolate-user-vlanenable;设置主vlan

[SwitchA]isolate-user-vlansecondary;设置主vlan包括的子vlan

[Quidway-Ethernet0/2]porthybridpvidvlan;设置vlan的pvid

[Quidway-Ethernet0/2]porthybridpvid;删除vlan的pvid

[Quidway-Ethernet0/2]porthybridvlanvlan_id_listuntagged;设置无标识的vlan

如果包的vlanid与PVId一致,则去掉vlan信息.默认PVID=1。

所以设置PVID为所属vlanid,设置可以互通的vlan为untagged.


华为路由器交换机配置命令:路由器命令


[Quidway]displayversion;显示版本信息

[Quidway]displaycurrent-configuration;显示当前配置

[Quidway]displayinterfaces;显示接口信息

[Quidway]displayiproute;显示路由信息

[Quidway]sysnameaabbcc;更改主机名

[Quidway]superpasswrod123456;设置口令

[Quidway]interfaceserial0;进入接口

[Quidway-serial0]ipaddress;配置端口IP地址

[Quidway-serial0]undoshutdown;激活端口

[Quidway]link-protocolhdlc;绑定hdlc协议

[Quidway]user-interfacevty04

[Quidway-ui-vty0-4]authentication-modepassword

[Quidway-ui-vty0-4]setauthentication-modepasswordsimple222

[Quidway-ui-vty0-4]userprivilegelevel3

[Quidway-ui-vty0-4]quit

[Quidway]debugginghdlcallserial0;显示所有信息

[Quidway]debugginghdlceventserial0;调试事件信息

[Quidway]debugginghdlcpacketserial0;显示包的信息


华为路由器交换机配置命令:静态路由:


[Quidway]iproute-static{interfacenumbernexthop}[value][rejectblackhole]

例如:

[Quidway]iproute-static129.1.0.01610.0.0.2

[Quidway]iproute-static129.1.0.0255.255.0.010.0.0.2

[Quidway]iproute-static129.1.0.016Serial2

[Quidway]iproute-static0.0.0.00.0.0.010.0.0.2



华为路由器交换机配置命令:动态路由:



[Quidway]rip;设置动态路由

[Quidway]ripwork;设置工作允许

[Quidway]ripinput;设置入口允许

[Quidway]ripoutput;设置出口允许

[Quidway-rip]network1.0.0.0;设置交换路由网络

[Quidway-rip]networkall;设置与所有网络交换

[Quidway-rip]peerip-address;

[Quidway-rip]summary;路由聚合

[Quidway]ripversion1;设置工作在版本1

[Quidway]ripversion2multicast;设版本2,多播方式

[Quidway-Ethernet0]ripsplit-horizon;水平分隔

[Quidway]routeridA.B.C.D;配置路由器的ID

[Quidway]ospfenable;启动OSPF协议

[Quidway-ospf]import-routedirect;引入直联路由

[Quidway-Serial0]ospfenablearea;配置OSPF区域



华为路由器交换机配置命令:标准访问列表命令格式如下:



acl[match-orderconfigauto];默认前者顺序匹配。

rule[normalspecial]{permitdeny}[sourcesource-addrsource-wildcardany]

例:

[Quidway]acl10

[Quidway-acl-10]rulenormalpermitsource10.0.0.00.0.0.255

[Quidway-acl-10]rulenormaldenysourceany



华为路由器交换机配置命令:扩展访问控制列表配置命令



配置TCP/UDP协议的扩展访问列表:

rule{normalspecial}{permitdeny}{tcpudp}source{any}destinationany}

[operate]

配置ICMP协议的扩展访问列表:

rule{normalspecial}{permitdeny}icmpsource{any]destination{any]

[icmp-code][logging]



华为路由器交换机配置命令:扩展访问控制列表操作符的含义



equalportnumber;等于

greater-thanportnumber;大于

less-thanportnumber;小于

not-equalportnumber;不等

rangeportnumber1portnumber2;区间



华为路由器交换机配置命令:扩展访问控制列表举例[Quidway]acl101

[Quidway-acl-101]

[Quidway-acl-101]-typeecho

[Quidway-acl-101]-typeecho-reply

[Quidway]acl102

[Quidway-acl-102]rulepermitipsource10.0.0.10.0.0.0destination202.0.0.10.0.0.0

[Quidway-acl-102]

[Quidway]acl103

[Quidway-acl-103].0.0.10.0.0.0destination-portequalftp

[Quidway-acl-103].0.0.20.0.0.0destination-portequalwww

[Quidway]firewallenable

[Quidway]firewalldefaultpermitdeny

[Quidway]inte0

[Quidway-Ethernet0]firewallpacket-filter101inboundoutbound



华为路由器交换机配置命令:地址转换配置举例



[Quidway]firewallenable

[Quidway]firewalldefaultpermit

[Quidway]acl101;内部指定主机可以进入e0

[Quidway-acl-101]

[Quidway-acl-101]rulepermitipsource129.38.1.10destinationany

[Quidway-acl-101]rulepermitipsource129.38.1.20destinationany

[Quidway-acl-101]rulepermitipsource129.38.1.30destinationany

[Quidway-acl-101]rulepermitipsource129.38.1.40destinationany

[Quidway-acl-101]quit

[Quidway]inte0

[Quidway-Ethernet0]firewallpacket-filter101inbound

[Quidway]acl102;外部特定主机和大于1024端口的数据包允许进入S0

[Quidway-acl-102]

[Quidway-acl-102]rulepermittcpsource202.39.2.30destination202.38.160.10

[Quidway-acl-102].38.160.10destination-portgreat-than

1024

[Quidway-acl-102]quit

[Quidway]ints0

[Quidway-Serial0]firewallpacket-filter102inbound;设202.38.160.1是路由器出口IP。

[Quidway-Serial0]natoutbound101interface;是Easyip,将acl101允许的IP从本接口出时变换源地址。



华为路由器交换机配置命令:内部服务器地址转换配置命令(静态nat):



natserverglobal[port]insideport[protocol];global_port不写时使用inside_port

[Quidway-Serial0]natserverglobal202.38.160.1inside129.38.1.1ftptcp

[Quidway-Serial0]natserverglobal202.38.160.1inside129.38.1.2telnettcp

[Quidway-Serial0]natserverglobal202.38.160.1inside129.38.1.3wwwtcp

设有公网IP:202.38.160.101~202.38.160.103可以使用。;对外访问(原例题)

[Quidway]nataddress-group202.38.160.101202.38.160.103pool1;建立地址池

[Quidway]acl1

[Quidway-acl-1]rulepermitsource10.110.10.00.0.0.255;指定允许的内部网络

[Quidway-acl-1]ruledenysourceany

[Quidway-acl-1]intserial0

[Quidway-Serial0]natoutbound1address-grouppool1;在s0口从地址池取出IP对外访问

[Quidway-Serial0]natserverglobal202.38.160.101inside10.110.10.1ftptcp

[Quidway-Serial0]natserverglobal202.38.160.102inside10.110.10.2wwwtcp

[Quidway-Serial0]natserverglobal202.38.160.1028080inside10.110.10.3wwwtcp

[Quidway-Serial0]natserverglobal202.38.160.103inside10.110.10.4smtpudp



华为路由器交换机配置命令:PPP设置:



[Quidway-s0]link-protocolppp;默认的协议



华为路由器交换机配置命令:PPP验证:



主验方:papchap

[Quidway]local-userq2password{simplecipher}hello;路由器1

[Quidway]interfaceserial0

[Quidway-serial0]pppauthentication-mode{papchap}

[Quidway-serial0]pppchapuserq1;pap时,没有此句



华为路由交换机配置命令:pap被验方:



[Quidway]interfaceserial0;路由器2

[Quidway-serial0]ppppaplocal-userq2password{simplecipher}hello



华为路由器交换机配置命令:chap被验方:



[Quidway]interfaceserial0;路由器2

[Quidway-serial0]pppchapuserq2;自己路由器名

[Quidway-serial0]local-userq1password{simplecipher}hello;对方路由器名

帧中继frame-relay(二分册6-61)

[q1]frswitching

[q1]ints1

[q1-Serial1]ipaddress192.168.34.51255.255.255.0

[q1-Serial1]link-protocolfr;封装帧中继协议

[q1-Serial1]frinterface-typedce

[q1-Serial1]frdlci100

[q1-Serial1]frinarp

[q1-Serial1]frmapip192.168.34.52dlci100

[q2]ints1

[q2-Serial1]ipaddress192.168.34.52255.255.255.0

[q2-Serial1]link-protocolfr

[q2-Serial1]frinterface-typedte

[q2-Serial1]frdlci100

[q2-Serial1]frinarp

[q2-Serial1]frmapip192.168.34.51dlci100



华为路由器交换机配置命令:帧中继监测



[q1]displayfrlmi-info[]interfacetypenumber]

[q1]displayfrmap

[q1]displayfrpvc-info[serialinterface-number][dlcidlci-number]

[q1]displayfrdlci-switch

[q1]displayfrinterface

[q1]resetfrinarp-info

[q1]debuggingfrall[interfacetypenumber]

[q1]debuggingfrarp[interfacetypenumber]

[q1]debuggingfrevent[interfacetypenumber]

[q1]debuggingfrlmi[interfacetypenumber]



华为路由器交换机配置命令:启动ftp服务:



[Quidway]local-userftppassword{simplecipher}aaaservice-typeftp

[Quidway]ftpserverenable 路由器交换机
交换机命令
[Quidway]super password 修改特权用户密码
[Quidway]sysname 交换机命名
[Quidway]interface ethernet 0/1 进入接口视图
[Quidway]interface vlan x 进入接口视图
[Quidway-Vlan-interfacex]ip address 10.65.1.1 255.255.0.0
[Quidway]ip route-static 0.0.0.0 0.0.0.0 10.65.1.2 静态路由=网关
[Quidway]user-interface vty 0 4
[S3026-ui-vty0-4]authentication-mode password
[S3026-ui-vty0-4]set authentication-mode password simple 222
[S3026-ui-vty0-4]user privilege level 3
[Quidway-Ethernet0/1]plex {half|full|auto} 配置端口双工工作状态
[Quidway-Ethernet0/1]speed {10|100|auto} 配置端口工作速率
[Quidway-Ethernet0/1]flow-control 配置端口流控
[Quidway-Ethernet0/1]mdi {across|auto|normal} 配置端口MDI/MDIX状态平接或扭接
[Quidway-Ethernet0/1]port link-type {trunk|access|hybrid} 设置接口工作模式
(access(缺省)不支持802.1q帧的传送,而trunk支持(用于Switch间互连),hybrid和trunk的区别在于trunk 只允许缺省VLAN的报文发送时不打标签,而hybrid允许多个VLAN报文发送时不打标签。 )
[Quidway-Ethernet0/1]shutdown 关闭/重起接口
[Quidway-Ethernet0/2]quit 退出系统视图
------------------------------------
[Quidway]vlan 3 创建/删除一个VLAN/进入VLAN模式
[Quidway-vlan3]port ethernet 0/1 to ethernet 0/4 在当前VLAN增加/删除以太网接口
[Quidway-Ethernet0/2]port access vlan 3 将当前接口加入到指定VLAN
[Quidway-Ethernet0/2]port trunk permit vlan {ID|All} 设trunk允许的VLAN
[Quidway-Ethernet0/2]port trunk pvid vlan 3 设置trunk端口的PVID
[Quidway]monitor-port 指定和清除镜像端口
[Quidway]port mirror 指定和清除被镜像端口
[Quidway]port mirror int_list observing-port int_type int_num 指定镜像和被镜像
[Quidway]description string 指定VLAN描述字符
[Quidway]description 删除VLAN描述字符
[Quidway]display vlan [vlan_id] 查看VLAN设置
[Quidway]stp {enable|disable} 开启/关闭生成树,默认关闭
[Quidway]stp priority 4096 设置交换机的优先级
[Quidway]stp root {primary|secondary} 设置交换机为根或根的备份
[Quidway-Ethernet0/1]stp cost 200 设置交换机端口的花费
[SwitchA-vlanx]isolate-user-vlan enable 设置主vlan
[SwitchA]Isolate-user-vlan secondary 设置主vlan包括的子vlan
[Quidway-Ethernet0/2]port hybrid pvid vlan 设置vlan的pvid
[Quidway-Ethernet0/2]port hybrid pvid 删除vlan的pvid
[Quidway-Ethernet0/2]port hybrid vlan vlan_id_list untagged 设置无标识的vlan
如果包的vlan id与PVId一致,则去掉vlan信息. 默认PVID=1。
所以设置PVID为所属vlan id, 设置可以互通的vlan为untagged.
端口聚合配置命令
[Quidway]link-aggregation ethernet 0/7 to ethernet 0/10 {ingress|both} 配置端口聚合
Port_num1为端口聚合组的起始端口号,Port_num2为终止端口号,ingress为接口入负荷分担方式,both为接口出入双向负荷分担方式。
[SwitchA]display link-aggregation ethernet0/1
[SwitchA]undo link-aggregation all
------------------------------------
路由器命令
[Quidway]display version 显示版本信息
[Quidway]display current-configuration 显示当前配置
[Quidway]display interfaces 显示接口信息
[Quidway]display ip route 显示路由信息
[Quidway]sysname aabbcc 更改主机名
[Quidway]super passwrod 123456 设置口令
[Quidway]interface serial0 进入接口
[Quidway-serial0]ip address
[Quidway-serial0]undo shutdown 激活端口
[Quidway]link-protocol hdlc 绑定hdlc协议
[Quidway]user-interface vty 0 4
[Quidway-ui-vty0-4]authentication-mode password
[Quidway-ui-vty0-4]set authentication-mode password simple 222
[Quidway-ui-vty0-4]user privilege level 3
[Quidway-ui-vty0-4]quit
[Quidway]debugging hdlc all serial0 显示所有信息
[Quidway]debugging hdlc event serial0 调试事件信息
[Quidway]debugging hdlc packet serial0 显示包的信息
静态路由:
[Quidway]ip route-static {interface number|nexthop}[value][reject|blackhole]
例如:
[Quidway]ip route-static 129.1.0.0 16 10.0.0.2
[Quidway]ip route-static 129.1.0.0 255.255.0.0 10.0.0.2
[Quidway]ip route-static 129.1.0.0 16 Serial 2
[Quidway]ip route-static 0.0.0.0 0.0.0.0 10.0.0.2
动态路由:
[Quidway]rip
[Quidway]rip work
[Quidway]rip input
[Quidway]rip output
[Quidway-rip]network 1.0.0.0 ;可以all
[Quidway-rip]network 2.0.0.0
[Quidway-rip]peer ip-address
[Quidway-rip]summary
[Quidway]rip version 1
[Quidway]rip version 2 multicast
[Quidway-Ethernet0]rip split-horizon ;水平分隔
[Quidway]router id A.B.C.D 配置路由器的ID
[Quidway]ospf enable 启动OSPF协议
[Quidway-ospf]import-route direct 引入直联路由
[Quidway-Serial0]ospf enable area
配置OSPF区域
标准访问列表命令格式如下:
acl [match-order config|auto] 默认前者顺序匹配。
rule [normal|special]{permit|deny} [source source-addr source-wildcard|any]
例:
[Quidway]acl 10
[Quidway-acl-10]rule normal permit source 10.0.0.0 0.0.0.255
[Quidway-acl-10]rule normal deny source any
扩展访问控制列表配置命令
配置TCP/UDP协议的扩展访问列表:
rule {normal|special}{permit|deny}{tcp|udp}source {|any}destination |any}
[operate]
配置ICMP协议的扩展访问列表:
rule {normal|special}{permit|deny}icmp source {|any]destination {|any]
[icmp-code] [logging]
扩展访问控制列表操作符的含义
equal portnumber 等于
greater-than portnumber 大于
less-than portnumber 小于
not-equal portnumber 不等
range portnumber1 portnumber2 区间
扩展访问控制列表举例
[Quidway]acl 101
[Quidway-acl-101]rule deny souce any destination any
[Quidway-acl-101]rule permit icmp source any destination any icmp-type echo
[Quidway-acl-101]rule permit icmp source any destination any icmp-type echo-reply
[Quidway]acl 102
[Quidway-acl-102]rule permit ip source 10.0.0.1 0.0.0.0 destination 202.0.0.1 0.0.0.0
[Quidway-acl-102]rule deny ip source any destination any
[Quidway]acl 103
[Quidway-acl-103]rule permit tcp source any destination 10.0.0.1 0.0.0.0 destination-port equal ftp
[Quidway-acl-103]rule permit tcp source any destination 10.0.0.2 0.0.0.0 destination-port equal www
[Quidway]firewall enable
[Quidway]firewall default permit|deny
[Quidway]int e0
[Quidway-Ethernet0]firewall packet-filter 101 inbound|outbound
地址转换配置举例
[Quidway]firewall enable
[Quidway]firewall default permit
[Quidway]acl 101
[Quidway-acl-101]rule deny ip source any destination any
[Quidway-acl-101]rule permit ip source 129.38.1.4 0 destination any
[Quidway-acl-101]rule permit ip source 129.38.1.1 0 destination any
[Quidway-acl-101]rule permit ip source 129.38.1.2 0 destination any
[Quidway-acl-101]rule permit ip source 129.38.1.3 0 destination any
[Quidway]acl 102
[Quidway-acl-102]rule permit tcp source 202.39.2.3 0 destination 202.38.160.1 0
[Quidway-acl-102]rule permit tcp source any destination 202.38.160.1 0 destination-port great-than
1024
[Quidway-Ethernet0]firewall packet-filter 101 inbound
[Quidway-Serial0]firewall packet-filter 102 inbound
[Quidway]nat address-group 202.38.160.101 202.38.160.103 pool1
[Quidway]acl 1
[Quidway-acl-1]rule permit source 10.110.10.0 0.0.0.255
[Quidway-acl-1]rule deny source any
[Quidway-acl-1]int serial 0
[Quidway-Serial0]nat outbound 1 address-group pool1
[Quidway-Serial0]nat server global 202.38.160.101 inside 10.110.10.1 ftp tcp
[Quidway-Serial0]nat server global 202.38.160.102 inside 10.110.10.2 www tcp
[Quidway-Serial0]nat server global 202.38.160.102 8080 inside 10.110.10.3 www tcp
[Quidway-Serial0]nat server global 202.38.160.103 inside 10.110.10.4 smtp udp
PPP配置命令
[Quidway-Serial0]link-protocol ppp 封装PPP协议
[Quidway-Serial0]ppp authentication-mode {pap|chap} 设置验证类型
证类型
[Quidway]local-user username password {simple|cipher} password 配置用户列表
PPP验证:
主验方:pap|chap
[Quidway]local-user u2 password {simple|cipher} aaa
[Quidway]interface serial 0
[Quidway-serial0]ppp authentication-mode {pap|chap}
[Quidway-serial0]ppp chap user u1 //pap时,不用此句
pap被验方:
[Quidway]interface serial 0
[Quidway-serial0]ppp pap local-user u2 password {simple|cipher} aaa
chap被验方:
[Quidway]interface serial 0
[Quidway-serial0]ppp chap user u1
[Quidway-serial0]local-user u2 password {simple|cipher} aaa

⑷ 静态路由配置

这一整个地址就是PC2所在的网段的网络地址啊,PC2的地址是192.168.4.66/24,网络地址就是192.168.4.0/24。这里配置静态路由,你看下PC2的地址,因为在R1上配置静态路由,这里的NET要写的就是目标的网段,也就是PC2所在的网段网络地址也就是192.168.4.0/24了。

⑸ linux网络配置问题

解决步骤如下:
1)确定你本地有dhcp服务,也就是负责分配192.168.1.X端IP的服务器或者小路由器。
2)cat /etc/sysconfig/network-scripts/ifcfg-eth2 #检查eth2的配置,是否如下

DEVICE=eth2
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
3)ifdown eth2 && ifup eth2 或者ifconfig eth2 down && ifconfig eth2 up

⑹ linux下配置网络连接

linux 命令配置网络连接首先,先了解传统的网络设置命令:
1. 使用ifconfig命令设置并查看网络接口情况
示例1: 设置eth0的IP,同时激活设备:
# ifconfig eth0 192.168.4.1 netmask 255.255.255.0 up
示例2: 设置eth0别名设备 eth0:1 的IP,并添加路由
# ifconfig eth0:1 192.168.4.2
# route add ?host 192.168.4.2 dev eth0:1
示例3:激活(禁用)设备
# ifconfig eth0:1 up(down)
示例4:查看所有(指定)网络接口设置
# ifconfig (eth0)
2. 使用route 命令设置路由表
示例1:添加到主机路由
# route add ?host 192.168.4.2 dev eth0:1
# route add ?host 192.168.4.1 gw 192.168.4.250
示例2:添加到网络的路由
# route add ?net IP netmask MASK eth0
# route add ?net IP netmask MASK gw IP
# route add ?net IP/24 eth1
示例3:添加默认网关
# route add default gw IP
示例4:删除路由
# route del ?host 192.168.4.1 dev eth0:1
示例5:查看路由信息
# route 或 route -n (-n 表示不解析名字,列出速度会比route 快)
3.ARP 管理命令
示例1:查看ARP缓存
# arp
示例2: 添加
# arp ?s IP MAC
示例3: 删除
# arp ?d IP
4. ip是iproute2软件包里面的一个强大的网络设置工具,他能够替代一些传统的网络管理工具。例如:ifconfig、route等,
上面的示例完万能用下面的ip命令实现,而且ip命令能实现更多的功能.下面介绍一些示例:
4.0 ip命令的语法
ip命令的用法如下:
ip [OPTIONS] OBJECT [COMMAND [ARGUMENTS]]
4.1 ip link set--改动设备的属性. 缩写:set、s
示例1:up/down 起动/关闭设备。
# ip link set dev eth0 up
这个等于传统的 # ifconfig eth0 up(down)
示例2:改动设备传输队列的长度。
参数:txqueuelen NUMBER或txqlen NUMBER
# ip link set dev eth0 txqueuelen 100
示例3:改动网络设备MTU(最大传输单元)的值。
# ip link set dev eth0 mtu 1500
示例4: 修改网络设备的MAC地址。
参数: address LLADDRESS
# ip link set dev eth0 address 00:01:4f:00:15:f1
4.2 ip link show--显示设备属性. 缩写:show、list、lst、sh、ls、l
-s选项出现两次或更多次,ip会输出更为周详的错误信息统计。
示例:
# ip -s -s link ls eth0
eth0: mtu 1500 qdisc cbq qlen 100
link/ether 00:a0:cc:66:18:78 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
2449949362 2786187 0 0 0 0
RX errors: length crc frame fifo missed
0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
178558497 1783946 332 0 332 35172
TX errors: aborted fifo window heartbeat
0 0 0 332
这个命令等于传统的 ifconfig eth0
5.1 ip address add--添加一个新的协议地址. 缩写:add、a
示例1:为每个地址设置一个字符串作为标签。为了和Linux-2.0的网络别名兼容,这个字符串必须以设备名开头,接着一个冒号,
# ip addr add local 192.168.4.1/28 brd + label eth0:1 dev eth0
示例2: 在以太网接口eth0上增加一个地址192.168.20.0,掩码长度为24位(155.155.155.0),标准广播地址,标签为eth0:Alias:
# ip addr add 192.168.4.2/24 brd + dev eth1 label eth1:1
这个命令等于传统的: ifconfig eth1:1 192.168.4.2
5.2 ip address delete--删除一个协议地址. 缩写:delete、del、d
# ip addr del 192.168.4.1/24 brd + dev eth0 label eth0:Alias1
5.3 ip address show--显示协议地址. 缩写:show、list、lst、sh、ls、l
# ip addr ls eth0
5.4.ip address flush--清除协议地址. 缩写:flush、f
示例1 : 删除属于私网10.0.0.0/8的所有地址:
# ip -s -s a f to 10/8
示例2 : 取消所有以太网卡的IP地址
# ip -4 addr flush label "eth0"
6. ip neighbour--neighbour/arp表管理命令
缩写 neighbour、neighbor、neigh、n
命令 add、change、replace、delete、fulsh、show(或list)
6.1 ip neighbour add -- 添加一个新的邻接条目
ip neighbour change--修改一个现有的条目
ip neighbour replace--替换一个已有的条目
缩写:add、a;change、chg;replace、repl
示例1: 在设备eth0上,为地址10.0.0.3添加一个permanent ARP条目:
# ip neigh add 10.0.0.3 lladdr 0:0:0:0:0:1 dev eth0 nud perm
示例2:把状态改为reachable
# ip neigh chg 10.0.0.3 dev eth0 nud reachable
6.2.ip neighbour delete--删除一个邻接条目
示例1:删除设备eth0上的一个ARP条目10.0.0.3
# ip neigh del 10.0.0.3 dev eth0
6.3.ip neighbour show--显示网络邻居的信息. 缩写:show、list、sh、ls
示例1: # ip -s n ls 193.233.7.254
193.233.7.254. dev eth0 lladdr 00:00:0c:76:3f:85 ref 5 used 12/13/20 nud reachable
6.4.ip neighbour flush--清除邻接条目. 缩写:flush、f
示例1: (-s 能显示周详信息)
# ip -s -s n f 193.233.7.254
7. 路由表管理
7.1.缩写 route、ro、r
7.5.路由表
从Linux-2.2开始,内核把路由归纳到许多路由表中,这些表都进行了编号,编号数字的范围是1到255。另外,
为了方便,还能在/etc/iproute2/rt_tables中为路由表命名。
默认情况下,所有的路由都会被插入到表main(编号254)中。在进行路由查询时,内核只使用路由表main。
7.6.ip route add -- 添加新路由
ip route change -- 修改路由
ip route replace -- 替换已有的路由
缩写:add、a;change、chg;replace、repl
示例1: 设置到网络10.0.0/24的路由经过网关193.233.7.65
# ip route add 10.0.0/24 via 193.233.7.65
示例2: 修改到网络10.0.0/24的直接路由,使其经过设备mmy
# ip route chg 10.0.0/24 dev mmy
示例3: 实现链路负载平衡.加入缺省多路径路由,让ppp0和ppp1分担负载(注意:scope值并非必需,他只不过是告诉内核,
这个路由要经过网关而不是直连的。实际上,如果你知道远程端点的地址,使用via参数来设置就更好了)。
# ip route add default scope global nexthop dev ppp0 nexthop dev ppp1
# ip route replace default scope global nexthop dev ppp0 nexthop dev ppp1
示例4: 设置NAT路由。在转发来自192.203.80.144的数据包之前,先进行网络地址转换,把这个地址转换为193.233.7.83
# ip route add nat 192.203.80.142 via 193.233.7.83
示例5: 实现数据包级负载平衡,允许把数据包随机从多个路由发出。weight 能设置权重.
# ip route replace default equalize nexthop via 211.139.218.145 dev eth0 weight 1 nexthop via 211.139.218.145 dev eth1 weight 1
7.7.ip route delete-- 删除路由
缩写:delete、del、d
示例1:删除上一节命令加入的多路径路由
# ip route del default scope global nexthop dev ppp0 nexthop dev ppp1
7.8.ip route show -- 列出路由
缩写:show、list、sh、ls、l
示例1: 计算使用gated/bgp协议的路由个数
# ip route ls proto gated/bgp |wc
1413 9891 79010
示例2: 计算路由缓存里面的条数,由于被缓存路由的属性可能大于一行,以此需要使用-o选项
# ip -o route ls cloned |wc
159 2543 18707
示例3: 列出路由表TABLEID里面的路由。缺省设置是table main。TABLEID或是个真正的路由表ID或是/etc/iproute2/rt_tables文件定义的字符串,
或是以下的特别值:
all -- 列出所有表的路由;
cache -- 列出路由缓存的内容。
ip ro ls 193.233.7.82 tab cache
示例4: 列出某个路由表的内容
# ip route ls table fddi153
示例5: 列出默认路由表的内容
# ip route ls
这个命令等于传统的: route
7.9.ip route flush -- 擦除路由表
示例1: 删除路由表main中的所有网关路由(示例:在路由监视程式挂掉之后):
# ip -4 ro flush scope global type unicast
示例2:清除所有被克隆出来的IPv6路由:
# ip -6 -s -s ro flush cache
示例3: 在gated程式挂掉之后,清除所有的BGP路由:
# ip -s ro f proto gated/bgp
示例4: 清除所有ipv4路由cache
# ip route flush cache
*** IPv4 routing cache is flushed.
7.10 ip route get -- 获得单个路由 .缩写:get、g
使用这个命令能获得到达目的地址的一个路由及他的确切内容。
ip route get命令和ip route show命令执行的操作是不同的。ip route show命令只是显示现有的路由,而ip route get命令在必要时会派生出新的路由。
示例1: 搜索到193.233.7.82的路由
# ip route get 193.233.7.82
193.233.7.82 dev eth0 src 193.233.7.65 realms inr.ac cache mtu 1500 rtt 300
示例2: 搜索目的地址是193.233.7.82,来自193.233.7.82,从eth0设备到达的路由(这条命令会产生一条非常有意思的路由,这是一条到193.233.7.82的回环路由)
# ip r g 193.233.7.82 from 193.233.7.82 iif eth0
193.233.7.82 from 193.233.7.82 dev eth0 src 193.233.7.65 realms inr.ac/inr.ac
cache mtu 1500 rtt 300 iif eth0
8. ip route -- 路由策略数据库管理命令
命令add、delete、show(或list)
注意:策略路由(policy routing)不等于路由策略(rouing policy)。
在某些情况下,我们不只是需要通过数据包的目的地址决定路由,可能还需要通过其他一些域:源地址、IP协议、传输层端口甚至数据包的负载。
这就叫做:策略路由(policy routing)。
8.5. ip rule add -- 插入新的规则
ip rule delete -- 删除规则
缩写:add、a;delete、del、d
示例1: 通过路由表inr.ruhep路由来自源地址为192.203.80/24的数据包
ip ru add from 192.203.80/24 table inr.ruhep prio 220
示例2:把源地址为193.233.7.83的数据报的源地址转换为192.203.80.144,并通过表1进行路由
ip ru add from 193.233.7.83 nat 192.203.80.144 table 1 prio 320
示例3:删除无用的缺省规则
ip ru del prio 32767
8.7. ip rule show -- 列出路由规则
缩写:show、list、sh、ls、l
示例1: # ip ru ls
0: from all lookup local
32762: from 192.168.4.89 lookup fddi153
32764: from 192.168.4.88 lookup fddi153
32766: from all lookup main
32767: from all lookup 253
9. ip maddress -- 多播地址管理
缩写:show、list、sh、ls、l
9.3.ip maddress show -- 列出多播地址
示例1: # ip maddr ls mmy
9.4. ip maddress add -- 加入多播地址
ip maddress delete -- 删除多播地址
缩写:add、a;delete、del、d
使用这两个命令,我们能添加/删除在网络接口上监听的链路层多播地址。这个命令只能管理链路层地址。
示例1: 增加 # ip maddr add 33:33:00:00:00:01 dev mmy
示例2: 查看 # ip -O maddr ls mmy
2: mmy
link 33:33:00:00:00:01 users 2 static
link 01:00:5e:00:00:01
示例3: 删除 # ip maddr del 33:33:00:00:00:01 dev mmy
10.ip mroute -- 多播路由缓存管理
10.4. ip mroute show -- 列出多播路由缓存条目
缩写:show、list、sh、ls、l
示例1:查看 # ip mroute ls
(193.232.127.6, 224.0.1.39) Iif: unresolved
(193.232.244.34, 224.0.1.40) Iif: unresolved
(193.233.7.65, 224.66.66.66) Iif: eth0 Oifs: pimreg
示例2:查看 # ip -s mr ls 224.66/16
(193.233.7.65, 224.66.66.66) Iif: eth0 Oifs: pimreg
9383 packets, 300256 bytes
11. ip tunnel -- 通道设置
缩写tunnel、tunl
11.4.ip tunnel add -- 添加新的通道
ip tunnel change -- 修改现有的通道
ip tunnel delete -- 删除一个通道
缩写:add、a;change、chg;delete、del、d
示例1:建立一个点对点通道,最大TTL是32
# ip tunnel add Cisco mode sit remote 192.31.7.104 local 192.203.80.1 ttl 32
11.4.ip tunnel show -- 列出现有的通道
缩写:show、list、sh、ls、l
示例1: # ip -s tunl ls Cisco
12. ip monitor和rtmon -- 状态监视
ip命令能用于连续地监视设备、地址和路由的状态。这个命令选项的格式有点不同,命令选项的名字叫做monitor,接着是操作对象:
ip monitor [ file FILE ] [ all | OBJECT-LIST ]
示例1: # rtmon file /var/log/rtmon.log
示例2: # ip monitor file /var/log/rtmon.log r

⑺ 几条网络相关命令--ifconfig,ping,traceroute,route,netstat

broadcast选项 :设置广播地址,虽说可根据IP和netmask自动计算出,但未防止ping
广播风暴,也有人另外设置合法的IP地址.
ifconfig eth0 ip netmask add1
broadcast add2metric N:This parameter sets the interface metric.
mtu N:This parameter sets the Maximum Transfer Unit (MTU) of an interface.
add addr/prefixlen :
Add an IPv6 address to an interface.
del addr/prefixlen :
Remove an IPv6 address from an interface.
pointopoint [addr]:设置点到点的直接连接
tunnel aa.bb.cc.dd :和VPN有关
Create a new SIT (IPv6-in-IPv4) device, tunnelling to the given destination.
hw class hwaddress:设置MAC地址(其中class包括ether(Ethernet), ax25 (AMPR AX.25), ARCnet and netrom(AMPR NET/ROM).)
ifconfigeth0 hw etherhwaddressroute可以设置网关
netstat的 -i -f net(这个偶机器上没有,--inet|--p)
ping -R :记录路由(这个实际显示的顺序和TCP/IP书上说的有些差别)
比如说ping -R 58.192.114.8得到如下结果:
RR: 10.14.2.9010.0.0.2610.0.0.2
58.192.114.1
58.192.114.8
10.0.0.1
10.0.0.2510.14.0.1
10.14.2.90而traceroute -n 58.192.114.8得到:
1 10.14.0.1 0.683 ms 0.834 ms 0.936 ms
2 10.0.0.25 0.357 ms 0.447 ms 0.497 ms
3 10.0.0.1 0.356 ms 0.427 ms 0.484 ms
4 58.192.114.8 0.401 ms 0.395 ms 0.393 msTCP协议有些东西搞的还不是太懂,待以后慢慢消化.

⑻ ifconfig配置ip

一、ifconfig与IP
1、ifconfig添加或修改原IP
ifconfig eth0 192.168.10.199 或
ifconfig eth0 192.168.10.199 netmask 255.255.255.0 up
ifconfig eth0:1 192.168.10.198 netmask 255.255.255.0 up

注:以上两台效果是一样的,上面一种写法是下面一种写法的减缩版。如果eth0上之前已经配置这IP,该配置会将原来的IP清掉,换成上面配置的IP,但在远程ssh时最好不要使用该方法,因为网络环境不同。一旦更改不生效,就要跑到机房再进行配置。
2、禁用启用网卡
ifconfig eth0 down
ifconfig eth0 up

该用法,是不是和ifup eth0、ifdown eth0:1很像?
注:当一块网卡上配置多个IP时,如eth0、eth0:1时,如果禁掉eth0:1时,eth0上的网卡配置依然生效。但禁掉直接物理网卡口时(即eth0)时,其后面配置的IP (eth0:1等)都将被删除掉。另外,ifconfig 还可以用于设置mtu和设置网卡的混杂模式:
ifconfig eth0 mtu 1472
利用netstat -i查看
将eth0设置成混杂模式
ifconfig eth0 promisc
取消混杂
ifconfig eth0 -promisc

3、修改网卡mac地址:
ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx

ifconfig查看的信息里,经常被我们忽视的第三行非常有用,如在没有mii-tool工具时,可以通过其查看网卡连接状态。
UP(代表网卡开启状态)RUNNING(代表网卡的网线被接上)MULTICAST(支持组播)MTU:1500(最大传输单元):1500字节
二、ip命令与IP
ip是iproute2软件包里面的一个强大的网络配置工具,它能够替代一些传统的网络管理工具,例如ifconfig、route等,使用权限为超级用户。
1、ip命令添加一个IP地址:
[root@localhost ~]# ip addr add 192.168.10.198/24 dev eth0:1
[root@localhost ~]# ip addr add 192.168.10.199/24 dev eth0
[root@localhost ~]# ip -f inet addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
inet 192.168.10.26/24 brd 192.168.10.255 scope global eth0
inet 192.168.10.198/24 scope global secondary eth0
inet 192.168.10.199/24 scope global secondary eth0
[root@localhost ~]# ip addr add 192.168.10.200/24 dev eth0:3
[root@localhost ~]# ip -f inet addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
inet 192.168.10.26/24 brd 192.168.10.255 scope global eth0
inet 192.168.10.198/24 scope global secondary eth0
inet 192.168.10.199/24 scope global secondary eth0
inet 192.168.10.200/24 scope global secondary eth0

当然,上面的增加地址的写法,我们也可以使用以下两种方式增加,不过由于没有上面的写法容易记,我平时很少会用下面的方式增加:
ip addr add local 192.168.4.1/28 brd + label eth0:1 dev eth0
ip addr add 192.168.4.2/24 brd + dev eth1 label eth1:1

由上面的操作命令不难看出,随便我们怎么去添加IP,后面的设备名无论是eth0、eth0:1、eth0:100也好,其都不会将原网卡上绑定的地址给清掉。其通过ip addr show 显示的出的结果都是secondary eth0 。
注:ip addr命令增加的IP ,不能通过ifconfig查看到,也不能通过ifconfig eth0:1 down 或ifdown eth0:1 这样的方式停掉。
2、ip命令删除一个IP
[root@localhost ~]# ip addr del 192.168.10.200
Not enough information: "dev" argument is required.
[root@localhost ~]# ip addr del 192.168.10.200 dev eth0
Warning: Executing wildcard deletion to stay compatible with old scripts.
Explicitly specify the prefix length (192.168.10.200/32) to avoid this warning.
This special behaviour is likely to disappear in further releases,
fix your scripts!
[root@localhost ~]# ip addr show
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 40:61:86:98:95:05 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.26/24 brd 192.168.10.255 scope global eth0
inet 192.168.10.198/24 scope global secondary eth0
inet 192.168.10.199/24 scope global secondary eth0
inet6 fe80::4261:86ff:fe98:9505/64 scope link
valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
[root@localhost ~]# ip addr del 192.168.10.199/24 dev eth0

在不加掩码删除时,其会提示警告,但还是可以将其地址删掉。ip命令的用法比较多,就不一一列举了。
三、路由配置
增加路由

route add -net 192.168.6.0/24 gw 192.168.101.254
route add default gw 192.168.101.254

查看路由
ip route list
route –n
netstat –r

四、总结
以上的ifconfig和ip命令配置的信息,重启都会清除,想要永久生效,还是配置相关的配置文件。不过掌握命令配置方法很重要,在LVS+keepalive等架构上,浮动IP的变动,很多都是通过ip命令来完成的。

⑼ 请教linux下双网卡的主备设置

一、安装的前提条件
确保安装了网卡并工作正常使用命令#ifconfig eth0查看网卡状态2.在系统中不要设置默认路由(网关),让ADSL拨号后自动获得如果已经设置了默认路由,使用以下方法删除:在文件 /etc/sysconfig/network 中删除 GATEWAY= 这一行,然后以root执行:#/etc/rc.d/init.d/network restart 3.已经安装了pppd软件包如果存在文件 /usr/sbin/pppd,则说明已经安装了pppd;如未安装,从RedHatLinux 安装光盘上装ppp-2.3.11-4.i386.rpm(版本可能不一样)这个软件包
二、安装PPPOE客户端软件
Linux下的PPPOE客户端软件比较多,而且大多使用GNU License,推荐使用rp-pppoe这个软件包,从这个网站上,不仅可以下栽RedHat 平台下的rp-pppoe的二进制软件包,而且可以下栽源代码软件包。二进制软件包的安装:
A.下栽二进制软件包
B.进行安装以root执行:#rpm -Uvh rp-pppoe-3.5-1.i386.rpm 2.从源代码进行安装:从源代码进行安装同样适用于其它平台的Linux,但必须在Linux系统中安装gcc编译器。
A.下栽源代码软件包
B.解压缩#tar xvfz rp-pppoe-3.5.tar.gz #cd rp-pppoe-3.5 C.进行编译和安装运行脚本#./go将自动进行编译和安装,最后,自动调用/usr/sbin/adsl-setup进行配置,具体解释见三。
三、配置PPPOE客户端软件
安装完软件包后,必须配置pppoe的配置文件/etc/ppp/pppoe.conf,从而让ADSL拨号时使用配置文件中的用户名、密码等参数。我们不必手工改动这个文件,可以使用adsl-setup这个工具进行配置:#/usr/sbin/adsl-setup当出现
Enter your PPPoE user name :
输入ADSL帐号的用户名当出现
Enter the Ethernet interface connected to the ADSL modem
For Solaris, this is likely to be something like /dev/hme0. For Linux, it will be ethn, where n is a number.(default eth0):输入 eth0 ,这是ADSL相连的网卡的名字当出现
Enter the demand value (default no):
输入 no当出现
Enter the DNS information here:
输入 “server” ,这表示使用ADSL拨号自动获得的DNS服务器IP地址当出现
Please enter your PPPoE password:
输入ADSL帐号的密码当出现
Choose a type of firewall (0-2):
输入 0 ,不使用防火墙当出现
Accept these settings and adjust configuration files (y/n)?
如果输入的信息正ā确,输入 y ,完成配置,否则,输入 n 重新输入。
四、启动PPPOE客户端软件
使用命令/usr/sbin/adsl-start 启动PPPOE客户端软件,进行连接,如果成功,将出现Connected;如果不成功,请检查网线、ADSL MODEM等物理设备,并查看 /var/log/messages中的信息/usr/sbin/adsl-stop 关闭和ISP的连接/usr/sbin/adsl-status 查看当前连接的状态如果想在Linux系统启动时自动启动ADSL连接,输入以下命令#chkconfig –add adsl将在当前的运行级下加入ADSL的自启动脚本。

⑽ 如何在Linux中为eth0增加一个路由

Linux下网卡命名规律:eth0,eth1。第一块以太网卡,第二块。lo为环回接口,它的IP地址固定为127.0.0.1,掩码8位。它代表你的机器本身。1、ifconfig是查看网卡的信息ifconfig[Interface]Interface是可选项,如果不加此项,则显示系统中所有网卡的信息。如果添加此选项则显示所指定的网卡信息.例如:ifconfigeth0eth0Linkencap:EthernetHWaddr00:0C:29:F3:3B:F2inetaddr:192.168.0.10Bcast:192.168.0.255Mask:255.255.255.:1500Metric:1RXpackets:78errors:0dropped:0overruns:0frame:0TXpackets:104errors:0dropped:0overruns:0carrier:0collisions:0txqueuelen:100RXbytes:11679(11.4Kb)TXbytes:14077(13.7Kb)Interrupt:10Baseaddress:0x1080可以看到:第一行:连接类型:Ethernet(以太网)HWaddr(硬件mac地址)第二行:网卡的IP地址、子网、掩码第三行:UP(代表网卡开启状态)RUNNING(代表网卡的网线被接上)MULTICAST(支持组播)MTU:1500(最大传输单元):1500字节第四、五行:接收、发送数据包情况统计第七行:接收、发送数据字节数统计信息。(1)配置eth0的IP地址,同时激活该设备。#ifconfigeth0192.168.1.10netmask255.255.255.0up(2)配置eth0别名设备eth0:1的IP地址,并添加路由。#ifconfigeth0:1192.168.1.3#routeadd–host192.168.1.3deveth0:1(3)激活设备。#ifconfigeth0:1up(4)禁用设备。#ifconfigeth0:down(5)查看指定的网络接口的配置。#ifconfigeth0(6)查看所有的网络接口配置。#ifconfig2、route命令来配置并查看内核路由表的配置情况例如:(1)添加到主机的路由。#routeadd–host192.168.1.2deveth0:0#routeadd–host10.20.30.148gw10.20.30.40(2)添加到网络的路由。#routeadd–net10.20.30.40netmask255.255.255.248eth0#routeadd–net10.20.30.48netmask255.255.255.248gw10.20.30.41#routeadd–net192.168.1.0/24eth1(3)添加默认网关。#routeadddefaultgw192.168.1.1(4)查看内核路由表的配置。#route(5)删除路由。#routedel–host192.168.1.2deveth0:0#routedel–host10.20.30.148gw10.20.30.40#routedel–net10.20.30.40netmask255.255.255.248eth0#routedel–net10.20.30.48netmask255.255.255.248gw10.20.30.41#routedel–net192.168.1.0/24eth1#routedeldefaultgw192.168.1.1对于1和2两点可使用下面的语句实现:Ifconfigeth0172.16.19.71netmask255.255.255.0Route0.0.0.0gw172.16.19.254Servicenetworkrestart3、traceroute命令显示数据包到达目的主机所经过的路由例如:#traceroute.cn4、ping命令来测试网络的连通性例如:#ping.cn#ping–c4192.168.1.125、netstat命令来显示网络状态信息

热点内容
宇宙中的二元论 发布:2025-09-11 02:17:03 浏览:741
区块链版权应用公司 发布:2025-09-11 02:10:38 浏览:70
跑usdt一天收入多少 发布:2025-09-11 02:05:38 浏览:389
目前有没有跟比特币一样的 发布:2025-09-11 02:05:36 浏览:363
区块链与个人发展有什么关系 发布:2025-09-11 01:59:46 浏览:970
android冷钱包 发布:2025-09-11 01:58:31 浏览:972
usdt混合钱包 发布:2025-09-11 01:50:00 浏览:588
trx4齿轮接合 发布:2025-09-11 01:16:57 浏览:639
宇宙二元学说 发布:2025-09-11 01:02:34 浏览:335
元宇宙硬件入口 发布:2025-09-11 00:47:38 浏览:932