Created
March 26, 2015 13:48
-
-
Save makeittotop/473d0186f5ca60bdc8ae to your computer and use it in GitHub Desktop.
Creates a new virtual network interface on linux
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Add a static route to a server on a separate lan | |
| # duplicate | |
| route add -net 172.17.0.0 netmask 255.255.255.0 gw 172.16.15.246 | |
| route | |
| netstat -rn | |
| # setup a virtual network interfece here | |
| ifconfig eth0:0 123.123.22.22 | |
| [root@bjlinux054 tactic_vm]# sudo service network restart | |
| Shutting down interface eth0: [ OK ] | |
| Shutting down loopback interface: [ OK ] | |
| Bringing up loopback interface: [ OK ] | |
| Bringing up interface eth0: [ OK ] | |
| [root@bjlinux054 tactic_vm]# ping 172.16.16.221 | |
| PING 172.16.16.221 (172.16.16.221) 56(84) bytes of data. | |
| 64 bytes from 172.16.16.221: icmp_seq=1 ttl=64 time=0.033 ms | |
| 64 bytes from 172.16.16.221: icmp_seq=2 ttl=64 time=0.033 ms | |
| ^C | |
| --- 172.16.16.221 ping statistics --- | |
| 2 packets transmitted, 2 received, 0% packet loss, time 1397ms | |
| rtt min/avg/max/mdev = 0.033/0.033/0.033/0.000 ms | |
| # Access it from another network by routing -- 172.16.15.246 | |
| abhishek@bjlinux068 /server/share_folder/Abhishek> sudo route add -net 172.16.16.0 netmask 255.255.255.0 gw 172.16.15.246 | |
| abhishek@bjlinux068 /server/share_folder/Abhishek> route | |
| Kernel IP routing table | |
| Destination Gateway Genmask Flags Metric Ref Use Iface | |
| 172.16.226.0 * 255.255.255.0 U 0 0 0 vmnet8 | |
| 172.16.113.0 * 255.255.255.0 U 0 0 0 vmnet1 | |
| 172.16.16.0 172.16.15.246 255.255.255.0 UG 0 0 0 eth0 | |
| 172.16.15.0 * 255.255.255.0 U 0 0 0 eth0 | |
| 172.16.11.0 * 255.255.255.0 U 0 0 0 eth0 | |
| 192.168.122.0 * 255.255.255.0 U 0 0 0 virbr0 | |
| link-local * 255.255.0.0 U 1002 0 0 eth0 | |
| 172.17.0.0 * 255.255.0.0 U 0 0 0 docker0 | |
| default 172.16.15.1 0.0.0.0 UG 0 0 0 eth0 | |
| abhishek@bjlinux068 /server/share_folder/Abhishek> ping 172.16.16.221 | |
| PING 172.16.16.221 (172.16.16.221) 56(84) bytes of data. | |
| 64 bytes from 172.16.16.221: icmp_seq=1 ttl=64 time=1.76 ms | |
| 64 bytes from 172.16.16.221: icmp_seq=2 ttl=64 time=0.496 ms | |
| 64 bytes from 172.16.16.221: icmp_seq=3 ttl=64 time=0.361 ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment