This command will add an IP route to the 172.29.59.1 router using the wlan0 wireless interface card on my laptop.
jason@darknet:~$ sudo ip route add 0/0 via 172.29.59.1 dev wlan0 |
This is part of the process of creating a network connection from your machine to a network when it is necessary to set IP addressing statically.
If the /sbin/ifconfig command will not list your network interface card, try the ip link
command.
jason@darknet:~$ ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether b8:ca:3a:c3:81:c4 brd ff:ff:ff:ff:ff:ff 3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000 link/ether f4:b7:e2:c9:1b:e3 brd ff:ff:ff:ff:ff:ff 4: vmnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000 link/ether 00:50:56:c0:00:01 brd ff:ff:ff:ff:ff:ff 5: vmnet8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 1000 link/ether 00:50:56:c0:00:08 brd ff:ff:ff:ff:ff:ff |
To set a static IP address on a network interface on Linux, do it this way. This is using a network mask of 255.255.255.0 or 11111111.11111111.11111111.00000000.
jason@darknet:~$ sudo /sbin/ifconfig wlan0 172.29.59.79/24 |
Now we have a statically assigned IP address on our network interface.
jason@darknet:~$ sudo /sbin/ifconfig wlan0 wlan0 Link encap:Ethernet HWaddr f4:b7:e2:c9:1b:e3 inet addr:172.29.59.79 Bcast:172.29.59.255 Mask:255.255.255.0 inet6 addr: fe80::f6b7:e2ff:fec9:1be3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:271481 errors:0 dropped:0 overruns:0 frame:0 TX packets:181989 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:266603848 (254.2 MiB) TX bytes:29934296 (28.5 MiB) |
If Internet connectivity is required, edit the /etc/resolv.conf file and add nameservers to allow the computer to resolve domain names and access websites.
jason@darknet:~$ cat /etc/resolv.conf # Generated by NetworkManager search det.nsw.edu.au nameserver 192.168.1.1 nameserver 8.8.8.8 nameserver 8.8.4.4 |
The above /etc/resolv.conf file is for a home user that has a router IP address of 192.168.1.1 and is wanting to use Google Domain Name Service to help resolve Internet IP addresses. I had to do this when trying to setup the Blackarch Linux distribution and it did not setup an Internet connection automatically. It was necessary to do this manually.