Linux Network Configuration


Basic System Configuration

IP configuration: 


GUI tool-

#system-config-network

CLI Tool-

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


#setup




Device Activation:

#/etc/init.d/NetworkManager restart
#service network restart
#service network stop
#service network start


DNS configuration:
#vi /etc/resolve.conf



Default gateway:

#setup
#system-config-network
#vi /etc/sysconfig/network-scripts/ifcfg-ethx


Managing Ethernet Connections: 

Network interface are named sequentially: 
eth0, eth1, etc. view interface configuration with ifconfig eth0

#ifconfig eth0 enable interface with ifup eth0
#ifup eth0 disable interface with ifdown eth0
#ifdown eth0

 other globle network setting :
if you want to modify your host name and gateway address manually.
 temporary basis:
#hostname name
permanent basic: 
#vi /etc/sysconfig/network
 NETWORKING=yes 
HOSTNAME=server1.redhat.com
GATEWAY=192.168.1.1
save and exit

 #service network restart

DNS Configuration:
1.domain name service translates hostname to network addresses
2. server address is specified by DHCP or /in /etc/resolve.conf
 #vi /etc/resolve.conf save and exit
#service network restart








Local name resolve configuration file

#vim /etc/hosts


IP address        hostname         alias
Reference “man hosts”

# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.100 server1.example.com   server1


Check the port number and routing command
route
traceroute
netstat
            ­r          ­           display the routing rable
            ­i          ­           display interface statistics
            ­t          ­           shows tcp connection
            ­u         ­           shows udp connection
            ­a         ­           display all sockets (tcp,udp or local)
            ­p         ­           display process IDs
            ­e         ­           display extended information
            ­l          ­           listening
            ­n         ­           numerical



# hostname
server1.example.com
# hostname ­d
example.com
# hostname ­s
server1
# hostname ­a
server1
# hostname ­f
server1.example.com
# hostname ­i
192.168.1.100
# hostname ­y


# iwconfig
lo        no wireless extensions.
eth0      no wireless extensions.
pan0      no wireless extensions.

# ethtool eth0
Settings for eth0:
                Supported ports: [ T P  ]
                Supported link modes:   10baseT /Half 10baseT /Full
                                        100baseT /Half 100baseT /Full
                                        1000baseT /Full
                Supports auto­negotiation: Yes
                Advertised link modes:  10baseT /Half 10baseT /Full
                                        100baseT /Half 100baseT /Full
                                        1000baseT /Full
                Advertised pause frame use: No
                Advertised auto­negotiation: Yes
                Speed: 1000Mb/s
                Duplex: Full
                P ort: T wisted P air
                P HYAD: 0
                T ransceiver: internal
                Auto­negotiation: on
                MDI­X: Unknown
                Supports Wake­on: d
                Wake­on: d
                Current message level: 0x00000007 (7)
                Link detected: yes

# ethtool ­i eth0
driver: e1000
version: 7.3.21­k6­1­NAPI
firmware­version: N/A
bus­info: 0000:02:01.0
ethtool –s eth0 speed 100 autoneg off
ethtool –S eth0

# mii­tool eth0
eth0: negotiated 100baseTx­FD, link ok

# host 192.168.1.100
100.1.168.192.in­addr.arpa domain name pointer server1.example.com.

# host server1.example.com
server1.example.com has address 192.168.1.100

# nslookup server1.example.com
Server:             192.168.1.100
Address:          192.168.1.100#53
Name:  server1.example.com
Address: 192.168.1.100

# nslookup 192.168.1.100
Server:             192.168.1.100
Address:          192.168.1.100#53
100.1.168.192.in­addr.arpa     name = server1.example.com.
[root@server1 Desktop]# dig server1.example.com
; <<>> DiG 9.7.3­P 3­RedHat­9.7.3­8.P 3.el6 <<>> server1.example.com
;; global options: +cmd
;; Got answer:
;; ­>>HEADER<<­ 11399="" id:="" noerror="" opcode:="" query="" span="" status:="">
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUT HORIT Y: 1, ADDIT IONAL: 0
;; QUEST ION SECT ION:
;server1.example.com.                             IN            A
;; ANSWER SECT ION:
server1.example.com.              86400      IN            A             192.168.1.100
;; AUT HORIT Y SECT ION:
example.com.                          86400      IN            NS           server1.example.com.
;; Query time: 0 msec
;; SERVER: 192.168.1.100#53(192.168.1.100)
;; WHEN: Sun Dec  2 21:56:55 2012
;; MSG SIZE  rcvd: 67

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     1      0        0 eth0
default         192.168.1.1     0.0.0.0         UG    0      0        0 eth0

# netstat ­r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     *               255.255.255.0   U         0 0          0 eth0
default         192.168.1.1     0.0.0.0         UG        0 0          0 eth0

# netstat ­tulnp | grep 22
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2184/sshd          
tcp        0      0 :::22                       :::*                        LISTEN      2184/sshd    

# nmap ­sTU ­p 21 192.168.1.100
Starting Nmap 5.21 ( http://nmap.org ) at 2012­12­02 22:05 IST
Nmap scan report for server1.example.com (192.168.1.100)
Host is up (0.00020s latency).
PORT   STATE  SERVICE
21/tcp open   ftp
21/udp closed ftp
Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds

# nmap ­sTU ­p 22 192.168.1.100
Starting Nmap 5.21 ( http://nmap.org ) at 2012­12­02 22:05 IST
Nmap scan report for server1.example.com (192.168.1.100)
Host is up (0.00042s latency).
PORT   STATE  SERVICE
22/tcp open   ssh
22/udp closed ssh
Nmap done: 1 IP address (1 host up) scanned in 0.03 seconds

No comments:

Post a Comment