Someone might attack on your system. You can drop attacker IP using IPtables. However, you can use route command to null route unwanted traffic. A null route (also called as blackhole route) is a network route or kernel routing table entry that goes nowhere. Matching packets are dropped (ignored) rather than forwarded, acting as a kind of very limited firewall. The act of using null routes is often called blackhole filtering. Show Sample Output
ip address show | grep eth0 | sed '1d' | awk '{print $2}'
does the same, but shows network-prefix.
Better use iproute2 !
Instead of hard-coding in a check to scrape info from ifconfig based on a specific interface, do it in a more portable way. This works really well if you switch between wired, wireless, bluetooth or even VPN connections. You can get your current IP in a script (since it'll be something like tun0 instead of eth0 or wlan1). This uses a well known public ip address 8.8.8.8, but it doesn't actually connect to it, it just shows you the route it would take. Show Sample Output
This gets you your default route programatically, useful for scripts
Useful to determine the source_ip of outgoing packages to a certain destination Show Sample Output
Can be used in a firewall script, e.g. to avoid logging broadcast packtes. Show Sample Output
oder: ip route get $(dig +short google.com | tail -1)
Plenty of commands out there for finding external IP, but sometimes getting the [internal] IP bound to the NIC handling Internet traffic is useful. Probably not production worthy, but a useful quick kludge. Assumes IPv4 and no fancy routing. Show Sample Output
add route default gateway on shell
Find your default gateway and print it directly output. http://www.bayner.com/ kerim@bayner.com Show Sample Output
Find your default gateway and print it directly output http://www.bilgisayarmatematik.com/ kerim@bayner.com Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: