- 论坛徽章:
- 13
|
本帖最后由 _nosay 于 2017-01-18 20:37 编辑
小记录:
①
A,B,C三类中有公网地址,也有私网地址:
在A类地址中,10.0.0.0到10.255.255.255是私有地址;
在B类地址中,172.16.0.0到172.31.255.255是私有地址;
在C类地址中,192.168.0.0到192.168.255.255是私有地址。
②
NAT:固定公网地址→固定内网地址
20.10.10.100:3456 → 192.168.10.37:3456
20.10.10.100:7000 → 192.168.10.37:7000
访问20.10.10.100的x端口,就是访问192.168.10.37的x端口
PAT:固定公网地址+随机端口→随机内网地址+随机端口
20.10.10.100:5678 → 192.168.10.37:7077
20.10.10.100:6789 → 192.168.10.100:3700
访问20.10.10.100的x端口,根据映射表记录,访问内网某台主机的某个端口
端口映射:固定公网地址+固定端口→固定内网地址+固定端口
20.10.10.100:8080 → 192.168.10.37:80
访问20.10.10.100:8080,就是访问192.168.10.37:80
- #include <stdio.h>
- #include <unistd.h>
- #include <getopt.h>
- // http://blog.csdn.net/cashey1991/article/details/7942809
- /*
- * ./a.out -a 10 -bc --config1 --config2 100
- * a, 544357864, 10, 3
- * b, 544357864, (null), 3
- * c, 544357864, (null), 4
- * ~, 0, (null), 5
- * !, 1, 100, 7
- */
- int main(int argc, char *argv[])
- {
- int opt, index;
- struct option opts[] = {
- { "config1", 0, NULL, '~' },
- { "config2", 1, NULL, '!' },
- { NULL, 0, NULL, 0 },
- };
- while ((opt = getopt_long(argc, argv, "a:bc", opts, &index)) != -1) {
- printf("%c, %d, %s, %d\n", opt, index, optarg, optind);
- }
- return 0;
- }
复制代码
|
|