[Linux] The command lines for network setting

[Linux] The command lines for network setting

1. IP and Subnet Mask setting

  • Assign IPv4 addresses to Network Interface
    $ ifconfig *interface* *IPv4 address*
    
    e.g:
    $ ifconfig eth0 192.168.10.91
    
  • Assign IPv6 address to Network Interface
    $ ifconfig *interface* inet6 add *IPv6 6Address*/*IPv6 Prefix Length*
    
    e.g: 
    $ ifconfig eth0 inet6 add 2001:b030:7015:ff01::1/64
    
  • Assign a IPv4 Subnet Mask to Network Interface
    $ ifconfig *interface* netmask *IPv4 Subnet Mask"
    
    e.g: 
    $ ifconfig eth0 netmask 255.255.255.0
    
  • 2. default gateway setting:
  • Assign IPv4 Gateway to Network Interface
    $ route add default gw *IPv4 Gateway* *interface*
    
    e.g:
    $ route add default gw 192.168.10.254 eth0
    
  • Assign IPv6 gateway
    $ route -A inet6 add default gw *IPv6 gateway*
    
    e.g: 
    $ route -A inet6 add default gw 2001:b030:7015:ff01::ffff
    
  • DNS setting:
    $ vim /etc/resolv.conf
    
    nameserver *ip adress*
    
    e.g:
    nameserver 8.8.8.8
    
(Visited 30 time, 1 visit today)
Facebooktwittergoogle_plusredditpinterestlinkedinmail
Comments are closed.