Host Name
View
[root@localhost ~]# hostnamelocalhost.localdomain[root@localhost ~]#
Temporary Modification
[root@localhost ~]# hostname centoscn[root@localhost ~]# hostnamecentoscn[root@localhost ~]#
Valid permanently
[root@localhost ~]# vim /etc/sysconfig/networkNETWORKING=yesHOSTNAME=centoscn
Host File
[Root @ localhost ~] # Vim/etc/hosts127.0.0.1 localhost. localdomain localhost4 localhost4.localdomain4 # we recommend that you keep this line 10.15.72.194 localhost justin localhost6 localhost6.localdomain6 # there must be three fields: IP, FQDN, and HOSTNAME
IP configuration
Temporary settings
[root@localhost ~]# ifconfig eth0 10.15.72.194 netmask 255.255.255.0
Valid permanently
[Root @ localhost ~] # Cd/etc/sysconfig/network-scripts/[root @ localhost network-scripts] # lsifcfg-eth0 ifdown-isdn ifup-aliases ifup-plusb init. ipv6-globalifcfg-lo ifdown-post ifup-bnep ifup-post net. hotplugifdown ifdown-ppp ifup-eth ifup-ppp network-functionsifdown-bnep ifdown-routes ifup-ippp ifup-routes network-functions-ipv6ifdown-eth ifdown-sit ifup-ipv6 ifup-sitifdown-ippp ifdown-tunnel ifup-isdn ifup-tunnelifdown-ipv6 ifup-plip ifup-wireless [root @ localhost network-scripts] # cp ifcfg-eth0 ifcfg-eth0bak # backup [root @ localhost network-scripts] # vim ifcfg-eth0DEVICE = eth0 # specify the device name NM_CONTROLLED = yes # parameters of network mamager, it takes effect in real time. You do not need to restart ONBOOT = yes # Set it to yes, and enable network connection IPADDR = 10.15.72.194 # IP address BOOTPROTO = static # Set it to none to disable DHCP, set static to enable static IP address, set dhcp to enable DHCP service NETMASK = 255.255.255.0 # subnet mask DNS1 = 8.8.8.8 # first dns server TYPE = Ethernet # network TYPE: ethernetGATEWAY = 10.15.72.254 # Set gateway DNS2 = 8.8.4.4 # Second dns server IPV6INIT = no # disable IPV6USERCTL = no # allow non-root users to control the device and set it to no, only root users can change HWADDR = 00: 0C: 29: 2C: E1: 0F # Nic Mac address PREFIX = 24 DEFROUTE = yesIPV4_FAILURE_FATAL = yesNAME = "System eth0" # define the device name
DEVICE, ONBOO, TBOOTPROTO, IPADDR, NETMASK, GATEWAY must be configured
Set Dual IP addresses for a single Nic
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0:0DEVICE=eth0:0 NM_CONTROLLED=yesONBOOT=yesIPADDR=10.15.72.195BOOTPROTO=static NETMASK=255.255.255.0DNS1=8.8.8.8 TYPE=Ethernet GATEWAY=10.15.72.254DNS2=8.8.4.4 IPV6INIT=no USERCTL=no HWADDR=00:0C:29:2C:E1:0FPREFIX=24DEFROUTE=yesIPV4_FAILURE_FATAL=yesNAME="System eth0:0"
Modify Mac address
[root@localhost network-scripts]# ifconfig eth0|grep HWaddeth0 Link encap:Ethernet HWaddr 00:0C:29:81:38:08[root@localhost network-scripts]# ifconfig eth0 down[root@localhost network-scripts]#ifconfig eth0 hw ether 00:0C:29:28:28:28[root@localhost network-scripts]# ifconfig eth0 | grep HWaddreth0 Link encap:Ethernet HWaddr 00:0C:29:28:28:28[root@localhost network-scripts]# ifconfig eth0 up
Routing
View
[root@localhost network-scripts]# routeKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface10.15.72.0 * 255.255.255.0 U 1 0 0 eth0default 10.15.72.254 0.0.0.0 UG 0 0 0 eth0[root@localhost network-scripts]# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface10.15.72.0 0.0.0.0 255.255.255.0 U 1 0 0 eth00.0.0.0 10.15.72.254 0.0.0.0 UG 0 0 0 eth0[root@localhost network-scripts]#
Add or delete static routes
[root@localhost network-scripts]# route add -net 10.15.72.194/24 gw 10.15.72.254[root@localhost network-scripts]# route del -net 10.15.72.194/24
Add or delete a default gateway
[root@localhost network-scripts]# route add default gw 10.15.72.254[root@localhost network-scripts]# route del default gw 10.15.72.254
Network Node Test
[root@localhost network-scripts]# traceroute 8.8.8.8tracerouteto 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets1 10.15.72.254 (10.15.72.254) 7.568 ms 7.880 ms 8.071 ms
Network connectivity test
[root@localhost network-scripts]# ping -c 5 8.8.8.8PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.64 bytes from 8.8.8.8: icmp_seq=2 ttl=46 time=32.3 ms64 bytes from 8.8.8.8: icmp_seq=3 ttl=46 time=31.8 ms64 bytes from 8.8.8.8: icmp_seq=4 ttl=46 time=33.4 ms--- 8.8.8.8 pingstatistics ---5 packets transmitted, 3 received, 40% packet loss, time5007msrtt min/avg/max/mdev= 31.891/32.554/33.458/0.662 ms[root@localhost network-scripts]#
ARP Information
[Root @ localhost network-scripts] # arp-n # view the ARP table of the current systemAddress HWtype HWaddress Flags Mask Iface10.15.72.254ether 08:d0:9f:e2:4d:c3 C eth010.15.72.73ether 00:25:64:a6:08:af C eth0[root@localhost network-scripts]# arp -s 10.15.72.25408: D0: 9f: e2: 4d: c3 # The Gateway binds an ip address to the mac address of the gateway.[root@localhost network-scripts]# arp -d 10.15.72.73# Deleting arp records
This article is from the "process is to achieve results" blog, please be sure to keep this source http://justinpeng.blog.51cto.com/7662323/1302137