-
-
Notifications
You must be signed in to change notification settings - Fork 483
Interface and Routes
Jason Lyu edited this page Feb 19, 2024
·
5 revisions
See also:
- https://www.cyberciti.biz/faq/linux-ip-command-examples-usage-syntax/
- https://www.linode.com/docs/guides/how-to-use-the-linux-ip-command/
The syntax is as follows to add an IPv4/IPv6 address:
ip addr add {ip_addr/mask} dev {interface}
To add a new route, the syntax is:
ip route add {NETWORK/MASK} via {GATEWAYIP}
ip route add {NETWORK/MASK} dev {DEVICE}
## Add default route using ip ##
ip route add default {NETWORK/MASK} dev {DEVICE}
ip route add default {NETWORK/MASK} via {GATEWAYIP}
For example, to Add a plain route to network 192.168.1.0/24
via gateway 192.168.1.254
:
ip route add 192.168.1.0/24 via 192.168.1.254
ifconfig <interface> <address> netmask <netmask>
ifconfig <interface> inet6 <address> prefixlen <prefixlength>
netsh interface ip set address <interface> static <address> <netmask>
netsh interface ipv6 add address <interface> static <address/prefixlength>