标签:ifconfig 网络配置 link sys ica 虚拟网络 sysconf eth func
首先我们使用 ip addr查看IP信息
[root@redhat2 network-scripts]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 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 state UP qlen 1000 link/ether 00:0c:29:85:58:f1 brd ff:ff:ff:ff:ff:ff inet6 fe80::20c:29ff:fe85:58f1/64 scope link valid_lft forever preferred_lft forever
可以看出第一个是本地回环地址,第二个是我们使用的网卡信息。一般没人是没有inet等信息的。因为默认是不启动网卡的。
[root@redhat2 ~]# cd /etc/sysconfig/network-scripts/ #网络配置文件位置 [root@redhat2 network-scripts]# ls ifcfg-eth0(可以对网卡进行设置) ifdown-isdn ifup-aliases ifup-plusb init.ipv6-global ifcfg-lo ifdown-post ifup-bnep ifup-post net.hotplug ifdown ifdown-ppp ifup-eth ifup-ppp network-functions ifdown-bnep ifdown-routes ifup-ippp ifup-routes network-functions-ipv6 ifdown-eth ifdown-sit ifup-ipv6 ifup-sit ifdown-ippp ifdown-tunnel ifup-isdn ifup-tunnel ifdown-ipv6 ifup ifup-plip ifup-wireless [root@redhat2 network-scripts]#
查看配置文件
[root@redhat2 network-scripts]# vim ifcfg-eth0 DEVICE="eth0" BOOTPROTO="dhcp" HWADDR="00:0C:29:85:58:F1" NM_CONTROLLED="yes" ONBOOT="no" #默认是启动时不开启网卡,我们可以将这个设置为yes TYPE="Ethernet" UUID="dd04bdab-73cc-41aa-94a4-1837bff7c726"
然后重启网络
service network restart
发现有IP了
[root@redhat2 ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 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 state UP qlen 1000 link/ether 00:0c:29:85:58:f1 brd ff:ff:ff:ff:ff:ff inet 192.168.218.129/24 brd 192.168.218.255 scope global eth0 inet6 fe80::20c:29ff:fe85:58f1/64 scope link valid_lft forever preferred_lft forever [root@redhat2 ~]#
上面获取的地址,是我们自己在虚拟机的虚拟网络编辑器中设置的
ifup eth0 是启动网卡
ifdown eth0 是关闭网卡
标签:ifconfig 网络配置 link sys ica 虚拟网络 sysconf eth func
原文地址:https://www.cnblogs.com/ssyfj/p/9174597.html