Wednesday, November 16, 2016

Useful networking commands

  
1. Add a default gateway:
 
route add default gw {IP-ADDRESS} {INTERFACE-NAME}
 
for example:
  route add default gw 9.30.217.1 br-ex
 
 
2. Find the default gateway:
 
route -n
 
The destination with 0.0.0.0 should indicate the default gateway and its interface
 
3. How to assign ip, broadcast and netmask to an interface:
 
ifconfig eth0 172.16.25.125 netmask 255.255.255.224 broadcast 172.16.25.63
 
4. Assign ip, broadcast and netmask using ip command:
 
ip address add {IP_CIDR} brd + dev {INTERFACE-NAME} 
 
for example: 
 
    ip addr add 192.168.1.50/24 brd + dev eth0 
 
5. Add a default gateway using IP command:
 
ip route add default via {GATEWAY_IP_ADDRESS} dev {INTERFACE-NAME

for example:

   ip route add default via 9.30.217.1 dev br-ex
 

No comments:

Post a Comment