如何配置Linux系统的IP地址?

码农编程进阶笔记

共 4371字,需浏览 9分钟

 ·

2020-08-18 14:24

LinuxIP使Linux


VMwareLinux

Windows

已启用DHCP:是IP地址:192.168.1.2子网掩码:255.255.255.0默认网关:192.168.1.1DHCP服务器:192.168.1.1DNS服务器:192.168.1.1


Windows

VMwareLinuxCentOS6.6

ping

 ping

ping [-] IP-c-c 


ping 192.168.1.2Linux192.168.1.2 Ctrl+C 
ping -c 3 192.168.1.13
ping -c 3 www.baidu.comping


LinuxIP

  1. ifconfig

  2. setup

LinuxIP


1. ifconfig

ifconfigifconfig [] [IP]interface configurationroot



ifconfig IPLinux使eth0/etc/sysconfig/network-scripts/ifcfg-eth0


ifconfig

ifconfig   #Linux

[root@localhost ~]# ifconfigeth0      Link encap:Ethernet  HWaddr 00:0C:29:3E:9C:06            inet addr:192.168.200.128  Bcast:192.168.200.255  Mask:255.255.255.0          inet6 addr: fe80::20c:29ff:fe3e:9c06/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:2326 errors:0 dropped:0 overruns:0 frame:0          TX packets:520 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000           RX bytes:161222 (157.4 KiB)  TX bytes:51780 (50.5 KiB)          Interrupt:19 Base address:0x2000 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:65536  Metric:1          RX packets:0 errors:0 dropped:0 overruns:0 frame:0          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0           RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)


eth0 12eth1macHWaddr 00:0C:29:3E:9C:06IPinet addr:192.168.200.128lo eth0/etc/sysconfig/network-scripts/ifcfg-eth0LinuxONBOOT=yes退使service network restartifconfig


eth0IP

ifconfig eth0 192.168.1.3eth0IPLinuxipIP使DNS


ifconfigIP


2. setup

setup  redhat linuxCentOS

使 setup IPDNSsetup IP

setup便Linux使


3. 

/etc/sysconfig/network-scripts/ifcfg-eth0

IPIP

3.1 IP

DHCP使LinuxIP

vi /etc/sysconfig/network-scripts/ifcfg-eth0  #


ONBOOT=yesBOOTPROTO=dhcp


eth0

使dhcpIPDNS

service network restart     #使


3.2 IP

IPDNS

vi /etc/sysconfig/network-scripts/ifcfg-eth0   #

ONBOOT=yesBOOTPROTO=noneIPADDR=192.168.1.66NETMASK=255.255.255.0GATEWAY=192.168.1.1DNS1=192.168.1.1


使dhcpipBOOTPROTOnonestatic

IP

DNSDNS/etc/resolv.confDNSDNS/etc/resolv.conf


service network restart 

Linux使IP


IPIPLinuxIPLinux使IP便



4. 

VMware

  1. NAT

    



4.1 NAT

NATIPVMnet8IP192.168.200.1)


4.2 

IPVMnet1IP192.168.224.1)



4.3 

IP线IP192.168.1.2


LinuxNAT使

浏览 36
点赞
评论
收藏
分享

手机扫一扫分享

分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

分享
举报